mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
perf: query data AS OF SYSTEM TIME
(#5231)
Queries the data in the storage layser at the timestamp when the call hit the API layer
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/call"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
)
|
||||
@@ -94,7 +95,7 @@ func addProjectGrantMemberWithoutOwnerRemoved(eq map[string]interface{}) {
|
||||
}
|
||||
|
||||
func (q *Queries) ProjectGrantMembers(ctx context.Context, queries *ProjectGrantMembersQuery, withOwnerRemoved bool) (*Members, error) {
|
||||
query, scan := prepareProjectGrantMembersQuery()
|
||||
query, scan := prepareProjectGrantMembersQuery(ctx, q.client)
|
||||
eq := sq.Eq{ProjectGrantMemberInstanceID.identifier(): authz.GetInstance(ctx).InstanceID()}
|
||||
if !withOwnerRemoved {
|
||||
addProjectGrantMemberWithoutOwnerRemoved(eq)
|
||||
@@ -122,7 +123,7 @@ func (q *Queries) ProjectGrantMembers(ctx context.Context, queries *ProjectGrant
|
||||
return members, err
|
||||
}
|
||||
|
||||
func prepareProjectGrantMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members, error)) {
|
||||
func prepareProjectGrantMembersQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilder, func(*sql.Rows) (*Members, error)) {
|
||||
return sq.Select(
|
||||
ProjectGrantMemberCreationDate.identifier(),
|
||||
ProjectGrantMemberChangeDate.identifier(),
|
||||
@@ -142,7 +143,7 @@ func prepareProjectGrantMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memb
|
||||
LeftJoin(join(HumanUserIDCol, ProjectGrantMemberUserID)).
|
||||
LeftJoin(join(MachineUserIDCol, ProjectGrantMemberUserID)).
|
||||
LeftJoin(join(LoginNameUserIDCol, ProjectGrantMemberUserID)).
|
||||
LeftJoin(join(ProjectGrantColumnGrantID, ProjectGrantMemberGrantID)).
|
||||
LeftJoin(join(ProjectGrantColumnGrantID, ProjectGrantMemberGrantID) + db.Timetravel(call.Took(ctx))).
|
||||
Where(
|
||||
sq.Eq{LoginNameIsPrimaryCol.identifier(): true},
|
||||
).PlaceholderFormat(sq.Dollar),
|
||||
|
Reference in New Issue
Block a user