mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-24 09:20:26 +00:00
feat: sequence and timestamp on searchrequests (#468)
* feat: reread events * feat: sequence and timestamo on search requests * feat: sequence and timestamo on search requests * fix: better naming * fix: log errors * fix: read sequence before search request
This commit is contained in:
@@ -2,6 +2,7 @@ package eventstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/logging"
|
||||
admin_view "github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
||||
"github.com/caos/zitadel/internal/config/systemdefaults"
|
||||
iam_es_model "github.com/caos/zitadel/internal/iam/repository/view/model"
|
||||
@@ -44,16 +45,23 @@ func (repo *IamRepository) RemoveIamMember(ctx context.Context, userID string) e
|
||||
|
||||
func (repo *IamRepository) SearchIamMembers(ctx context.Context, request *iam_model.IamMemberSearchRequest) (*iam_model.IamMemberSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestIamMemberSequence()
|
||||
logging.Log("EVENT-Slkci").OnError(err).Warn("could not read latest iam sequence")
|
||||
members, count, err := repo.View.SearchIamMembers(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &iam_model.IamMemberSearchResponse{
|
||||
result := &iam_model.IamMemberSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: iam_es_model.IamMembersToModel(members),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *IamRepository) GetIamMemberRoles() []string {
|
||||
|
||||
@@ -2,6 +2,7 @@ package eventstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/logging"
|
||||
|
||||
admin_model "github.com/caos/zitadel/internal/admin/model"
|
||||
admin_view "github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
||||
@@ -72,16 +73,23 @@ func (repo *OrgRepo) OrgByID(ctx context.Context, id string) (*org_model.Org, er
|
||||
|
||||
func (repo *OrgRepo) SearchOrgs(ctx context.Context, query *org_model.OrgSearchRequest) (*org_model.OrgSearchResult, error) {
|
||||
query.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestOrgSequence()
|
||||
logging.Log("EVENT-LXo9w").OnError(err).Warn("could not read latest iam sequence")
|
||||
orgs, count, err := repo.View.SearchOrgs(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &org_model.OrgSearchResult{
|
||||
result := &org_model.OrgSearchResult{
|
||||
Offset: query.Offset,
|
||||
Limit: query.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.OrgsToModel(orgs),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *OrgRepo) IsOrgUnique(ctx context.Context, name, domain string) (isUnique bool, err error) {
|
||||
|
||||
Reference in New Issue
Block a user