mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Merge enqueued status into JobStatusChoices
This commit is contained in:
parent
15f888ca65
commit
7d15ec0bbb
@ -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,
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user