Ajout du cron pour l'import automatique
This commit is contained in:
parent
2275203ff9
commit
7faef3923f
@ -128,5 +128,37 @@ def run_recurrent_import(self, pk):
|
|||||||
close_import_task(self.request.id, False, e, importer)
|
close_import_task(self.request.id, False, e, importer)
|
||||||
|
|
||||||
|
|
||||||
|
@app.task(bind=True)
|
||||||
|
def daily_imports(self):
|
||||||
|
from agenda_culturel.models import RecurrentImport
|
||||||
|
logger.messages("Imports quotidiens")
|
||||||
|
imports = RecurrentImport.objects.filter(recurrence=RecurrentImport.RECURRENCE.DAILY)
|
||||||
|
|
||||||
|
for imp in imports:
|
||||||
|
run_recurrent_import.delay(imp.pk)
|
||||||
|
|
||||||
|
|
||||||
|
@app.task(bind=True)
|
||||||
|
def weekly_imports(self):
|
||||||
|
from agenda_culturel.models import RecurrentImport
|
||||||
|
logger.messages("Imports hebdomadaires")
|
||||||
|
imports = RecurrentImport.objects.filter(recurrence=RecurrentImport.RECURRENCE.WEEKLY)
|
||||||
|
|
||||||
|
for imp in imports:
|
||||||
|
run_recurrent_import.delay(imp.pk)
|
||||||
|
|
||||||
|
app.conf.beat_schedule = {
|
||||||
|
"daily_imports": {
|
||||||
|
"task": "agenda_culturel.celery.daily_imports",
|
||||||
|
# Daily imports at 3:14 a.m.
|
||||||
|
"schedule": crontab(hour=3, minute=14),
|
||||||
|
},
|
||||||
|
"weekly_imports": {
|
||||||
|
"task": "agenda_culturel.celery.weekly_imports",
|
||||||
|
# Daily imports on Mondays at 2:22 a.m.
|
||||||
|
"schedule": crontab(hour=2, minute=22, day_of_week='mon'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
app.conf.timezone = "Europe/Paris"
|
app.conf.timezone = "Europe/Paris"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user