2020-06-25 06:01:13 +00:00
|
|
|
package eventstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-12-18 15:47:45 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view"
|
|
|
|
view_model "github.com/zitadel/zitadel/internal/view/model"
|
|
|
|
"github.com/zitadel/zitadel/internal/view/repository"
|
2020-06-25 06:01:13 +00:00
|
|
|
)
|
|
|
|
|
2022-09-01 07:10:07 +00:00
|
|
|
var dbList = []string{"auth", "adminapi"}
|
2020-06-25 06:01:13 +00:00
|
|
|
|
|
|
|
type AdministratorRepo struct {
|
|
|
|
View *view.View
|
|
|
|
}
|
|
|
|
|
2022-11-18 12:49:38 +00:00
|
|
|
func (repo *AdministratorRepo) GetFailedEvents(ctx context.Context, instanceID string) ([]*view_model.FailedEvent, error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
allFailedEvents := make([]*view_model.FailedEvent, 0)
|
|
|
|
for _, db := range dbList {
|
2022-11-18 12:49:38 +00:00
|
|
|
failedEvents, err := repo.View.AllFailedEvents(db, instanceID)
|
2020-06-25 06:01:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
for _, failedEvent := range failedEvents {
|
|
|
|
allFailedEvents = append(allFailedEvents, repository.FailedEventToModel(failedEvent))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return allFailedEvents, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *AdministratorRepo) RemoveFailedEvent(ctx context.Context, failedEvent *view_model.FailedEvent) error {
|
|
|
|
return repo.View.RemoveFailedEvent(failedEvent.Database, repository.FailedEventFromModel(failedEvent))
|
|
|
|
}
|
|
|
|
|
2022-11-18 12:49:38 +00:00
|
|
|
func (repo *AdministratorRepo) GetViews(instanceID string) ([]*view_model.View, error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
views := make([]*view_model.View, 0)
|
|
|
|
for _, db := range dbList {
|
2022-11-18 12:49:38 +00:00
|
|
|
sequences, err := repo.View.AllCurrentSequences(db, instanceID)
|
2020-06-25 06:01:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
for _, sequence := range sequences {
|
|
|
|
views = append(views, repository.CurrentSequenceToModel(sequence))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return views, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *AdministratorRepo) ClearView(ctx context.Context, database, view string) error {
|
|
|
|
return repo.View.ClearView(database, view)
|
|
|
|
}
|