2020-07-08 11:56:37 +00:00
|
|
|
package admin
|
2020-06-25 06:01:13 +00:00
|
|
|
|
|
|
|
import (
|
2020-07-15 11:24:36 +00:00
|
|
|
"github.com/caos/logging"
|
2020-06-25 06:01:13 +00:00
|
|
|
view_model "github.com/caos/zitadel/internal/view/model"
|
2020-07-08 11:56:37 +00:00
|
|
|
"github.com/caos/zitadel/pkg/grpc/admin"
|
2020-07-15 11:24:36 +00:00
|
|
|
"github.com/golang/protobuf/ptypes"
|
2020-06-25 06:01:13 +00:00
|
|
|
)
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func viewsFromModel(views []*view_model.View) []*admin.View {
|
|
|
|
result := make([]*admin.View, len(views))
|
2020-06-25 06:01:13 +00:00
|
|
|
for i, view := range views {
|
|
|
|
result[i] = viewFromModel(view)
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func failedEventsFromModel(failedEvents []*view_model.FailedEvent) []*admin.FailedEvent {
|
|
|
|
result := make([]*admin.FailedEvent, len(failedEvents))
|
2020-06-25 06:01:13 +00:00
|
|
|
for i, view := range failedEvents {
|
|
|
|
result[i] = failedEventFromModel(view)
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func viewFromModel(view *view_model.View) *admin.View {
|
2020-12-02 07:50:59 +00:00
|
|
|
eventTimestamp, err := ptypes.TimestampProto(view.EventTimestamp)
|
|
|
|
logging.Log("GRPC-KSo03").OnError(err).Debug("unable to parse timestamp")
|
2020-12-14 10:49:20 +00:00
|
|
|
lastSpool, err := ptypes.TimestampProto(view.LastSuccessfulSpoolerRun)
|
|
|
|
logging.Log("GRPC-0oP87").OnError(err).Debug("unable to parse timestamp")
|
2020-07-15 11:24:36 +00:00
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
return &admin.View{
|
2020-12-02 07:50:59 +00:00
|
|
|
Database: view.Database,
|
|
|
|
ViewName: view.ViewName,
|
|
|
|
ProcessedSequence: view.CurrentSequence,
|
|
|
|
EventTimestamp: eventTimestamp,
|
|
|
|
LastSuccessfulSpoolerRun: lastSpool,
|
2020-06-25 06:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func failedEventFromModel(failedEvent *view_model.FailedEvent) *admin.FailedEvent {
|
|
|
|
return &admin.FailedEvent{
|
2020-06-25 06:01:13 +00:00
|
|
|
Database: failedEvent.Database,
|
|
|
|
ViewName: failedEvent.ViewName,
|
|
|
|
FailedSequence: failedEvent.FailedSequence,
|
|
|
|
FailureCount: failedEvent.FailureCount,
|
|
|
|
ErrorMessage: failedEvent.ErrMsg,
|
|
|
|
}
|
|
|
|
}
|