From c4e1a7ab75bccfb3c14cfd33b7c1791ba85bbeb7 Mon Sep 17 00:00:00 2001 From: William Peebles Date: Sun, 16 Apr 2023 15:24:51 -0400 Subject: [PATCH] add cleanupEvents to worker --- app/worker.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/worker.py b/app/worker.py index f9c54b0..6e1e617 100644 --- a/app/worker.py +++ b/app/worker.py @@ -1,6 +1,7 @@ from celery import Celery from celery.schedules import crontab from create_events import createEvents +from cleanup_events import cleanupEvents import os from flask import Flask from misc import currDay, datetime, time, timedelta @@ -32,11 +33,20 @@ def runCreateEvents(): with app.app_context(): createEvents(db, currDay, Period, Event) +def runCleanupEvents(): + with app.app_context(): + cleanupEvents(db, Event) + # Scheduled tasks celerymsg.conf.beat_schedule = { 'hourly-createevents': { 'task': 'worker.runCreateEvents', # Run hourly 'schedule': crontab(hour="*", minute="59"), + }, + 'monthly-cleanupevents': { + 'task': 'worker.runCleanupEvents', + # Run monthly + 'schedule': crontab(day_of_month="29") } } \ No newline at end of file