fix bug worker

This commit is contained in:
javad committed 2026-09-28 22:04:53 +03:30
1 parent 4525ec3e6a
commit 81335b1439
2 files changed
+24 -1

No files matched your search

+2 -1
View File
@@ -94,7 +94,8 @@ def process_due_announcements(*, job_id=None):
).update(status=AnnouncementJob.Status.PENDING, next_attempt_at=now)
with transaction.atomic():
queryset = (
AnnouncementJob.objects.select_for_update(skip_locked=True)
# Nullable message/ticket joins must not be included in FOR UPDATE on PostgreSQL.
AnnouncementJob.objects.select_for_update(skip_locked=True, of=("self",))
.filter(status=AnnouncementJob.Status.PENDING, next_attempt_at__lte=now)
.select_related("message__ticket__customer", "ticket__customer")
.annotate(priority=Case(When(source=AnnouncementJob.Source.MANUAL, then=Value(0)), default=Value(1), output_field=IntegerField()))