feat: Add admin tasks

This commit is contained in:
moanos [he/him] 2024-11-06 23:32:37 +01:00
parent 0b93b5eccb
commit 0c7080f005
2 changed files with 15 additions and 5 deletions

View File

@ -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")

View File

@ -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 != "":