mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-16 12:58:00 +00:00
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
|
package view
|
||
|
|
||
|
import (
|
||
|
"github.com/caos/zitadel/internal/errors"
|
||
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
||
|
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||
|
)
|
||
|
|
||
|
func ProjectByIDQuery(id string, latestSequence uint64) (*es_models.SearchQuery, error) {
|
||
|
if id == "" {
|
||
|
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-dke74", "Errors.Project.ProjectIDMissing")
|
||
|
}
|
||
|
return ProjectQuery(latestSequence).
|
||
|
AggregateIDFilter(id), nil
|
||
|
}
|
||
|
|
||
|
func ProjectQuery(latestSequence uint64) *es_models.SearchQuery {
|
||
|
return es_models.NewSearchQuery().
|
||
|
AggregateTypeFilter(model.ProjectAggregate).
|
||
|
LatestSequenceFilter(latestSequence)
|
||
|
}
|
||
|
|
||
|
func ChangesQuery(projectID string, latestSequence, limit uint64, sortAscending bool) *es_models.SearchQuery {
|
||
|
query := es_models.NewSearchQuery().
|
||
|
AggregateTypeFilter(model.ProjectAggregate)
|
||
|
if !sortAscending {
|
||
|
query.OrderDesc()
|
||
|
}
|
||
|
|
||
|
query.LatestSequenceFilter(latestSequence).
|
||
|
AggregateIDFilter(projectID).
|
||
|
SetLimit(limit)
|
||
|
return query
|
||
|
}
|