From 52214ed62a43ec7a5962948e1e8593c1461d2d8f Mon Sep 17 00:00:00 2001 From: SahilDhillon21 Date: Wed, 8 Jan 2025 14:26:26 +0530 Subject: [PATCH 1/3] add ap job scheduler --- website/apps.py | 4 ++++ website/scheduler_config.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 website/scheduler_config.py diff --git a/website/apps.py b/website/apps.py index 864790176..9a443deec 100644 --- a/website/apps.py +++ b/website/apps.py @@ -7,3 +7,7 @@ class WebsiteConfig(AppConfig): def ready(self): import website.signals # noqa + + from . import scheduler_config + + scheduler_config.start() diff --git a/website/scheduler_config.py b/website/scheduler_config.py new file mode 100644 index 000000000..22f2ef332 --- /dev/null +++ b/website/scheduler_config.py @@ -0,0 +1,12 @@ +from apscheduler.schedulers.background import BackgroundScheduler +from django.core.management import call_command + + +def MonitorJob(): + call_command("check_keywords") + + +def start(): + scheduler = BackgroundScheduler() + scheduler.add_job(MonitorJob, "interval", seconds=10) + scheduler.start() From b8dfa69addc1c4dded3cbdd274d908da07787f16 Mon Sep 17 00:00:00 2001 From: SahilDhillon21 Date: Wed, 8 Jan 2025 16:51:02 +0530 Subject: [PATCH 2/3] add ap shceduler to pyproject --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f74479c75..d4dba5bfc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,6 +83,7 @@ async-timeout = "^5.0.1" aiohttp = "^3.11.11" scout-apm = "^3.2.1" newrelic = "^10.4.0" +apscheduler="^3.11.0" [tool.poetry.group.dev.dependencies] black = "^24.8.0" From 914f3865aa614151c7b9c6b6abf826f14720c84f Mon Sep 17 00:00:00 2001 From: SahilDhillon21 Date: Thu, 9 Jan 2025 12:18:38 +0530 Subject: [PATCH 3/3] Set time interval to one week --- website/scheduler_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/scheduler_config.py b/website/scheduler_config.py index 22f2ef332..da747c873 100644 --- a/website/scheduler_config.py +++ b/website/scheduler_config.py @@ -8,5 +8,5 @@ def MonitorJob(): def start(): scheduler = BackgroundScheduler() - scheduler.add_job(MonitorJob, "interval", seconds=10) + scheduler.add_job(MonitorJob, "interval", weeks=1) scheduler.start()