Skip to content

Deprecation: improve Celery task db query #10414

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

Merged
merged 5 commits into from
Jun 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions readthedocs/projects/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ def deprecated_config_file_used_notification():
queryset = User.objects.filter(username__in=users, profile__banned=False).order_by(
"id"
)

# Exclude users that already have an unread notification.
# Our notifications backend already performs de-duplication of notifications automatically.
# However, this is only to speed up things here since this loop takes the most time.
queryset = queryset.exclude(
message__message__startswith="Your project(s)", message__read=False
)

n_users = queryset.count()
for i, user in enumerate(queryset.iterator()):
if i % 500 == 0:
Expand Down