2022-04-21 10:37:39 +00:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2022-11-18 12:49:38 +00:00
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
system_pb "github.com/zitadel/zitadel/pkg/grpc/system"
|
2022-04-21 10:37:39 +00:00
|
|
|
)
|
|
|
|
|
2022-05-31 14:33:50 +00:00
|
|
|
func FailedEventsToPb(database string, failedEvents *query.FailedEvents) []*system_pb.FailedEvent {
|
2022-04-21 10:37:39 +00:00
|
|
|
events := make([]*system_pb.FailedEvent, len(failedEvents.FailedEvents))
|
|
|
|
for i, failedEvent := range failedEvents.FailedEvents {
|
2022-05-31 14:33:50 +00:00
|
|
|
events[i] = FailedEventToPb(database, failedEvent)
|
2022-04-21 10:37:39 +00:00
|
|
|
}
|
|
|
|
return events
|
|
|
|
}
|
|
|
|
|
2022-05-31 14:33:50 +00:00
|
|
|
func FailedEventToPb(database string, failedEvent *query.FailedEvent) *system_pb.FailedEvent {
|
2022-11-18 12:49:38 +00:00
|
|
|
var lastFailed *timestamppb.Timestamp
|
|
|
|
if !failedEvent.LastFailed.IsZero() {
|
|
|
|
lastFailed = timestamppb.New(failedEvent.LastFailed)
|
|
|
|
}
|
2022-04-21 10:37:39 +00:00
|
|
|
return &system_pb.FailedEvent{
|
2022-05-31 14:33:50 +00:00
|
|
|
Database: database,
|
2022-04-21 10:37:39 +00:00
|
|
|
ViewName: failedEvent.ProjectionName,
|
|
|
|
FailedSequence: failedEvent.FailedSequence,
|
|
|
|
FailureCount: failedEvent.FailureCount,
|
|
|
|
ErrorMessage: failedEvent.Error,
|
2022-11-18 12:49:38 +00:00
|
|
|
LastFailed: lastFailed,
|
2022-04-21 10:37:39 +00:00
|
|
|
}
|
|
|
|
}
|