Skip to content

Commit 1e0d26a

Browse files
committed
celery: add async task to update the 'pending_review' attributes on all patches
Signed-off-by: andrepapoti <[email protected]>
1 parent 00ae28f commit 1e0d26a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

patchwork/tasks.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from celery import shared_task
2+
from patchwork.celery import app
3+
from patchwork.models import Patch
4+
from patchwork.api.patch import PatchInterestSerializer
5+
6+
7+
@shared_task
8+
def update_patch_interest():
9+
for patch in Patch.objects.all():
10+
pending_review = False
11+
for patch_interest in patch.interested_users.through.objects.filter(
12+
patch=patch
13+
):
14+
serializer = PatchInterestSerializer(patch_interest)
15+
if not serializer.data['is_stale']:
16+
pending_review = True
17+
break
18+
patch.pending_review = pending_review
19+
patch.save()
20+
21+
22+
app.conf.beat_schedule = {
23+
'update_patch_interest': {
24+
'task': 'patchwork.tasks.update_patch_interest',
25+
'schedule': 3600.0,
26+
}
27+
}

0 commit comments

Comments
 (0)