mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 05:13:49 +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:
@@ -89,16 +89,23 @@ func (repo *ProjectRepo) SearchProjects(ctx context.Context, request *proj_model
|
||||
request.Queries = append(request.Queries, &proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Method: global_model.SearchMethodIsOneOf, Value: ids})
|
||||
}
|
||||
|
||||
sequence, err := repo.View.GetLatestProjectSequence()
|
||||
logging.Log("EVENT-Edc56").OnError(err).Warn("could not read latest project sequence")
|
||||
projects, count, err := repo.View.SearchProjects(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ProjectViewSearchResponse{
|
||||
result := &proj_model.ProjectViewSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ProjectsToModel(projects),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectGrantViewByID(ctx context.Context, grantID string) (project *proj_model.ProjectGrantView, err error) {
|
||||
@@ -132,16 +139,23 @@ func (repo *ProjectRepo) RemoveProjectMember(ctx context.Context, projectID, use
|
||||
|
||||
func (repo *ProjectRepo) SearchProjectMembers(ctx context.Context, request *proj_model.ProjectMemberSearchRequest) (*proj_model.ProjectMemberSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestProjectMemberSequence()
|
||||
logging.Log("EVENT-3dgt6").OnError(err).Warn("could not read latest project member sequence")
|
||||
members, count, err := repo.View.SearchProjectMembers(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ProjectMemberSearchResponse{
|
||||
result := &proj_model.ProjectMemberSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ProjectMembersToModel(members),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) AddProjectRole(ctx context.Context, role *proj_model.ProjectRole) (*proj_model.ProjectRole, error) {
|
||||
@@ -194,18 +208,27 @@ func (repo *ProjectRepo) RemoveProjectRole(ctx context.Context, projectID, key s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) SearchProjectRoles(ctx context.Context, request *proj_model.ProjectRoleSearchRequest) (*proj_model.ProjectRoleSearchResponse, error) {
|
||||
func (repo *ProjectRepo) SearchProjectRoles(ctx context.Context, projectID string, request *proj_model.ProjectRoleSearchRequest) (*proj_model.ProjectRoleSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
request.AppendProjectQuery(projectID)
|
||||
sequence, err := repo.View.GetLatestProjectRoleSequence()
|
||||
logging.Log("LSp0d-47suf").OnError(err).Warn("could not read latest project role sequence")
|
||||
roles, count, err := repo.View.SearchProjectRoles(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ProjectRoleSearchResponse{
|
||||
|
||||
result := &proj_model.ProjectRoleSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ProjectRolesToModel(roles),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectChanges(ctx context.Context, id string, lastSequence uint64, limit uint64, sortAscending bool) (*proj_model.ProjectChanges, error) {
|
||||
@@ -254,16 +277,23 @@ func (repo *ProjectRepo) RemoveApplication(ctx context.Context, projectID, appID
|
||||
|
||||
func (repo *ProjectRepo) SearchApplications(ctx context.Context, request *proj_model.ApplicationSearchRequest) (*proj_model.ApplicationSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestApplicationSequence()
|
||||
logging.Log("EVENT-SKe8s").OnError(err).Warn("could not read latest application sequence")
|
||||
apps, count, err := repo.View.SearchApplications(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ApplicationSearchResponse{
|
||||
result := &proj_model.ApplicationSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ApplicationViewsToModel(apps),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ApplicationChanges(ctx context.Context, id string, appId string, lastSequence uint64, limit uint64, sortAscending bool) (*proj_model.ApplicationChanges, error) {
|
||||
@@ -299,16 +329,23 @@ func (repo *ProjectRepo) ProjectGrantByID(ctx context.Context, grantID string) (
|
||||
|
||||
func (repo *ProjectRepo) SearchProjectGrants(ctx context.Context, request *proj_model.ProjectGrantViewSearchRequest) (*proj_model.ProjectGrantViewSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestProjectGrantSequence()
|
||||
logging.Log("EVENT-Skw9f").OnError(err).Warn("could not read latest project grant sequence")
|
||||
projects, count, err := repo.View.SearchProjectGrants(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ProjectGrantViewSearchResponse{
|
||||
result := &proj_model.ProjectGrantViewSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ProjectGrantsToModel(projects),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) AddProjectGrant(ctx context.Context, grant *proj_model.ProjectGrant) (*proj_model.ProjectGrant, error) {
|
||||
@@ -430,16 +467,23 @@ func (repo *ProjectRepo) RemoveProjectGrantMember(ctx context.Context, projectID
|
||||
|
||||
func (repo *ProjectRepo) SearchProjectGrantMembers(ctx context.Context, request *proj_model.ProjectGrantMemberSearchRequest) (*proj_model.ProjectGrantMemberSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
sequence, err := repo.View.GetLatestProjectGrantMemberSequence()
|
||||
logging.Log("EVENT-Du8sk").OnError(err).Warn("could not read latest project grant sequence")
|
||||
members, count, err := repo.View.SearchProjectGrantMembers(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proj_model.ProjectGrantMemberSearchResponse{
|
||||
result := &proj_model.ProjectGrantMemberSearchResponse{
|
||||
Offset: request.Offset,
|
||||
Limit: request.Limit,
|
||||
TotalResult: uint64(count),
|
||||
Result: model.ProjectGrantMembersToModel(members),
|
||||
}, nil
|
||||
}
|
||||
if err == nil {
|
||||
result.Sequence = sequence.CurrentSequence
|
||||
result.Timestamp = sequence.CurrentTimestamp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) GetProjectMemberRoles() []string {
|
||||
|
||||
Reference in New Issue
Block a user