2022-04-21 12:37:39 +02:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2022-11-18 13:49:38 +01:00
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
"github.com/zitadel/zitadel/internal/view/model"
|
|
|
|
system_pb "github.com/zitadel/zitadel/pkg/grpc/system"
|
2022-04-21 12:37:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func ViewsToPb(views []*model.View) []*system_pb.View {
|
|
|
|
v := make([]*system_pb.View, len(views))
|
|
|
|
for i, view := range views {
|
|
|
|
v[i] = ViewToPb(view)
|
|
|
|
}
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func ViewToPb(view *model.View) *system_pb.View {
|
|
|
|
return &system_pb.View{
|
|
|
|
Database: view.Database,
|
|
|
|
ViewName: view.ViewName,
|
|
|
|
LastSuccessfulSpoolerRun: timestamppb.New(view.LastSuccessfulSpoolerRun),
|
|
|
|
ProcessedSequence: view.CurrentSequence,
|
|
|
|
EventTimestamp: timestamppb.New(view.EventTimestamp),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-31 16:33:50 +02:00
|
|
|
func CurrentSequencesToPb(database string, currentSequences *query.CurrentSequences) []*system_pb.View {
|
2022-04-21 12:37:39 +02:00
|
|
|
v := make([]*system_pb.View, len(currentSequences.CurrentSequences))
|
|
|
|
for i, currentSequence := range currentSequences.CurrentSequences {
|
2022-05-31 16:33:50 +02:00
|
|
|
v[i] = CurrentSequenceToPb(database, currentSequence)
|
2022-04-21 12:37:39 +02:00
|
|
|
}
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2022-05-31 16:33:50 +02:00
|
|
|
func CurrentSequenceToPb(database string, currentSequence *query.CurrentSequence) *system_pb.View {
|
2022-04-21 12:37:39 +02:00
|
|
|
return &system_pb.View{
|
2022-11-18 13:49:38 +01:00
|
|
|
Database: database,
|
|
|
|
ViewName: currentSequence.ProjectionName,
|
|
|
|
ProcessedSequence: currentSequence.CurrentSequence,
|
|
|
|
LastSuccessfulSpoolerRun: timestamppb.New(currentSequence.Timestamp),
|
2022-04-21 12:37:39 +02:00
|
|
|
}
|
|
|
|
}
|