mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 03:57:32 +00:00
fix: query optimisations (#1949)
* index on events for changes * check for current sequence before filter events
This commit is contained in:
@@ -43,7 +43,13 @@ func (repo *TokenVerifierRepo) TokenByID(ctx context.Context, tokenID, userID st
|
||||
token.UserID = userID
|
||||
}
|
||||
|
||||
events, esErr := repo.getUserEvents(ctx, userID, token.Sequence)
|
||||
sequence := token.Sequence
|
||||
currentSequence, err := repo.View.GetLatestTokenSequence()
|
||||
if err == nil {
|
||||
sequence = currentSequence.CurrentSequence
|
||||
}
|
||||
|
||||
events, esErr := repo.getUserEvents(ctx, userID, sequence)
|
||||
if caos_errs.IsNotFound(viewErr) && len(events) == 0 {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "EVENT-4T90g", "Errors.Token.NotFound")
|
||||
}
|
||||
|
Reference in New Issue
Block a user