schedula process_map_updates usind celery on new MapUpdate creation

This commit is contained in:
Laura Klünder 2017-11-10 16:56:50 +01:00
parent 0565869eb2
commit efbbbe2495
3 changed files with 31 additions and 15 deletions

View file

@ -0,0 +1,22 @@
from django.utils.formats import date_format
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from c3nav.celery import app
@app.task(rate_limit='1/m')
def process_map_updates():
from c3nav.mapdata.models import MapUpdate
updates = MapUpdate.process_updates()
if updates:
print()
print(ungettext_lazy('%d map update processed.', '%d map updates processed.', len(updates)) % len(updates))
if updates:
print(_('Last processed update: %(date)s (#%(id)d)') % {
'date': date_format(updates[-1].datetime, 'DATETIME_FORMAT'),
'id': updates[-1].pk,
})