From ba58d90bf7cfa9ae06a49eb30d201efcaa2d1ad6 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 1 Dec 2023 23:50:41 -0500 Subject: [PATCH] doorcontrol: Move task scheduling into doorcontrol.apps directly --- doorcontrol/apps.py | 13 +++++++++++-- doorcontrol/tasks/scrapehidevents.py | 11 ----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doorcontrol/apps.py b/doorcontrol/apps.py index 0938fb3..340959a 100644 --- a/doorcontrol/apps.py +++ b/doorcontrol/apps.py @@ -3,9 +3,18 @@ from django.db.models.signals import post_migrate def post_migrate_callback(sender, **kwargs): - from .tasks.scrapehidevents import schedule_tasks + from django_q.models import Schedule - schedule_tasks() + from cmsmanage.django_q2_helper import ensure_scheduled + + from .tasks.scrapehidevents import q_getMessagesAllDoors + + ensure_scheduled( + "Fetch HID Events", + q_getMessagesAllDoors, + schedule_type=Schedule.MINUTES, + minutes=15, + ) class DoorControlConfig(AppConfig): diff --git a/doorcontrol/tasks/scrapehidevents.py b/doorcontrol/tasks/scrapehidevents.py index 7c42f30..9d93f4b 100644 --- a/doorcontrol/tasks/scrapehidevents.py +++ b/doorcontrol/tasks/scrapehidevents.py @@ -4,9 +4,7 @@ from django.db import transaction from django.utils import timezone from django_q.tasks import async_task -from django_q.models import Schedule -from cmsmanage.django_q2_helper import ensure_scheduled from doorcontrol.models import Door, HIDEvent @@ -45,12 +43,3 @@ def q_getMessagesAllDoors(): cluster="internal", group=f"Fetch HID Events - {door.name}", ) - - -def schedule_tasks(): - ensure_scheduled( - "Fetch HID Events", - q_getMessagesAllDoors, - schedule_type=Schedule.MINUTES, - minutes=15, - )