Merge enqueued status into JobStatusChoices

This commit is contained in:
Alexander Haase 2024-07-24 10:01:23 +02:00
parent 15f888ca65
commit 7d15ec0bbb
2 changed files with 7 additions and 7 deletions

View File

@ -59,6 +59,12 @@ class JobStatusChoices(ChoiceSet):
(STATUS_FAILED, _('Failed'), 'red'),
)
ENQUEUED_STATE_CHOICES = (
STATUS_PENDING,
STATUS_SCHEDULED,
STATUS_RUNNING,
)
TERMINAL_STATE_CHOICES = (
STATUS_COMPLETED,
STATUS_ERRORED,

View File

@ -92,12 +92,6 @@ class ScheduledJob(BackgroundJob):
method is called.
"""
ENQUEUED_STATUS = [
JobStatusChoices.STATUS_PENDING,
JobStatusChoices.STATUS_SCHEDULED,
JobStatusChoices.STATUS_RUNNING,
]
@classmethod
def get_jobs(cls, instance):
"""
@ -139,7 +133,7 @@ class ScheduledJob(BackgroundJob):
instance: The NetBox object to which this `ScheduledJob` pertains
interval: Recurrence interval (in minutes)
"""
job = cls.get_jobs(instance).filter(status__in=cls.ENQUEUED_STATUS).first()
job = cls.get_jobs(instance).filter(status__in=JobStatusChoices.ENQUEUED_STATE_CHOICES).first()
if job:
# If the job parameters haven't changed, don't schedule a new job and keep the current schedule. Otherwise,
# delete the existing job and schedule a new job instead.