From 0c7080f0053170c940744e4a223e078f5eda2bcf Mon Sep 17 00:00:00 2001 From: moanos Date: Wed, 6 Nov 2024 23:32:37 +0100 Subject: [PATCH] feat: Add admin tasks --- src/fellchensammlung/tasks.py | 12 +++++++++--- src/notfellchen/celery.py | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/fellchensammlung/tasks.py b/src/fellchensammlung/tasks.py index 763ab38..a17fda3 100644 --- a/src/fellchensammlung/tasks.py +++ b/src/fellchensammlung/tasks.py @@ -1,6 +1,6 @@ from django.utils import timezone from notfellchen.celery import app as celery_app -from .tools.admin import clean_locations, deactivate_unchecked_adoption_notices +from .tools.admin import clean_locations, deactivate_unchecked_adoption_notices, deactivate_404_adoption_notices from .tools.misc import healthcheck_ok from .models import Location, AdoptionNotice, Timestamp @@ -19,10 +19,16 @@ def task_clean_locations(): set_timestamp("task_clean_locations") -@celery_app.task(name="admin.deactivate_unchecked") +@celery_app.task(name="admin.daily_unchecked_deactivation") def task_deactivate_unchecked(): deactivate_unchecked_adoption_notices() - set_timestamp("task_deactivate_unchecked") + set_timestamp("task_daily_unchecked_deactivation") + + +@celery_app.task(name="admin.deactivate_404_adoption_notices") +def task_deactivate_unchecked(): + deactivate_404_adoption_notices() + set_timestamp("task_deactivate_404_adoption_notices") @celery_app.task(name="commit.add_location") diff --git a/src/notfellchen/celery.py b/src/notfellchen/celery.py index 2b88c62..dfd2553 100644 --- a/src/notfellchen/celery.py +++ b/src/notfellchen/celery.py @@ -16,10 +16,14 @@ app.conf.beat_schedule = { 'task': 'admin.clean_locations', 'schedule': crontab(hour=2), }, - 'daily-deactivation': { - 'task': 'admin.deactivate_unchecked', + 'daily-unchecked-deactivation': { + 'task': 'admin.daily_unchecked_deactivation', 'schedule': crontab(hour=1), }, + 'daily-404-deactivation': { + 'task': 'admin.deactivate_404_adoption_notices', + 'schedule': crontab(hour=3), + }, } if settings.HEALTHCHECKS_URL is not None and settings.HEALTHCHECKS_URL != "":