2022-04-21 10:37:39 +00:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2022-04-26 23:01:45 +00: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 10:37:39 +00:00
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
)
|
|
|
|
|
|
|
|
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 14:33:50 +00:00
|
|
|
func CurrentSequencesToPb(database string, currentSequences *query.CurrentSequences) []*system_pb.View {
|
2022-04-21 10:37:39 +00:00
|
|
|
v := make([]*system_pb.View, len(currentSequences.CurrentSequences))
|
|
|
|
for i, currentSequence := range currentSequences.CurrentSequences {
|
2022-05-31 14:33:50 +00:00
|
|
|
v[i] = CurrentSequenceToPb(database, currentSequence)
|
2022-04-21 10:37:39 +00:00
|
|
|
}
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2022-05-31 14:33:50 +00:00
|
|
|
func CurrentSequenceToPb(database string, currentSequence *query.CurrentSequence) *system_pb.View {
|
2022-04-21 10:37:39 +00:00
|
|
|
return &system_pb.View{
|
2022-05-31 14:33:50 +00:00
|
|
|
Database: database,
|
2022-04-21 10:37:39 +00:00
|
|
|
ViewName: currentSequence.ProjectionName,
|
|
|
|
ProcessedSequence: currentSequence.CurrentSequence,
|
|
|
|
EventTimestamp: timestamppb.New(currentSequence.Timestamp),
|
|
|
|
}
|
|
|
|
}
|