-
Notifications
You must be signed in to change notification settings - Fork 838
use pk instead of id in clear expired tokens #1593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,7 +537,7 @@ def revoke(self): | |
| self = list(token)[0] | ||
|
|
||
| with suppress(access_token_model.DoesNotExist): | ||
| access_token_model.objects.get(id=self.access_token_id).revoke() | ||
| access_token_model.objects.get(pk=self.access_token_id).revoke() | ||
|
||
|
|
||
| self.access_token = None | ||
| self.revoked = timezone.now() | ||
|
|
@@ -815,9 +815,9 @@ def batch_delete(queryset, query): | |
| current_no = start_no = queryset.count() | ||
|
|
||
| while current_no: | ||
| flat_queryset = queryset.values_list("id", flat=True)[:CLEAR_EXPIRED_TOKENS_BATCH_SIZE] | ||
| flat_queryset = queryset.values_list("pk", flat=True)[:CLEAR_EXPIRED_TOKENS_BATCH_SIZE] | ||
| batch_length = flat_queryset.count() | ||
| queryset.model.objects.filter(id__in=list(flat_queryset)).delete() | ||
| queryset.model.objects.filter(pk__in=list(flat_queryset)).delete() | ||
|
Comment on lines
+818
to
+820
|
||
| logger.debug(f"{batch_length} tokens deleted, {current_no - batch_length} left") | ||
| queryset = queryset.model.objects.filter(query) | ||
| time.sleep(CLEAR_EXPIRED_TOKENS_BATCH_INTERVAL) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it will work