Skip to content

Commit dc08e98

Browse files
committed
Deprecation: improve Celery task db query
This commit excludes the users that already have an unread notification with this message. This is only to avoid performing db queries for users where our notification backend won't add a new notification anyways. This will improve the performance of this task making it to run faster (hopefully).
1 parent 8458022 commit dc08e98

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

readthedocs/projects/tasks/utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ def deprecated_config_file_used_notification():
271271
queryset = User.objects.filter(username__in=users, profile__banned=False).order_by(
272272
"id"
273273
)
274+
275+
# Exclude users that already have an unread notification.
276+
# Our notifications backend already performs de-duplication of notifications automatically.
277+
# However, this is only to speed up things here since this loop takes the most time.
278+
queryset = queryset.exclude(
279+
message__message__startswith="Your project(s)", message__read=False
280+
)
281+
274282
n_users = queryset.count()
275283
for i, user in enumerate(queryset.iterator()):
276284
if i % 500 == 0:

0 commit comments

Comments
 (0)