From 16d6c2c0fe0f81d12d8b0457e7f13e17d0a3559a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 27 Oct 2011 10:21:28 +0200 Subject: [PATCH] rebuild place/event matches once a day, this gets out of sync if new annotations are added --- pandora/event/tasks.py | 7 +++++++ pandora/place/tasks.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/pandora/event/tasks.py b/pandora/event/tasks.py index 37366683..b38a257b 100644 --- a/pandora/event/tasks.py +++ b/pandora/event/tasks.py @@ -7,6 +7,13 @@ from celery.decorators import task, periodic_task import models +@periodic_task(run_every=timedelta(days=1), queue='encoding') +def update_all_matches(**kwargs): + ids = [e['id'] for e in models.Event.objects.all().values('id')] + for i in ids: + e = models.Event.objects.get(pk=i) + e.update_matches() + @task(ignore_resulsts=True, queue='default') def update_matches(eventId): event = models.Event.objects.get(pk=eventId) diff --git a/pandora/place/tasks.py b/pandora/place/tasks.py index 3a276227..dc23ea7f 100644 --- a/pandora/place/tasks.py +++ b/pandora/place/tasks.py @@ -7,6 +7,13 @@ from celery.decorators import task, periodic_task import models +@periodic_task(run_every=timedelta(days=1), queue='encoding') +def update_all_matches(**kwargs): + ids = [p['id'] for p in models.Place.objects.all().values('id')] + for i in ids: + p = models.Place.objects.get(pk=i) + p.update_matches() + @task(ignore_resulsts=True, queue='default') def update_matches(id): place = models.Place.objects.get(pk=id)