start() and terminate() methods on Job should call save()

This commit is contained in:
jeremystretch 2023-03-29 09:45:34 -04:00
parent 177668dca5
commit 48ee8a94b4
2 changed files with 3 additions and 4 deletions

View File

@ -140,7 +140,7 @@ class Job(models.Model):
# Start the job # Start the job
self.started = timezone.now() self.started = timezone.now()
self.status = JobStatusChoices.STATUS_RUNNING self.status = JobStatusChoices.STATUS_RUNNING
Job.objects.filter(pk=self.pk).update(started=self.started, status=self.status) self.save()
# Handle webhooks # Handle webhooks
self.trigger_webhooks(event=EVENT_JOB_START) self.trigger_webhooks(event=EVENT_JOB_START)
@ -156,7 +156,7 @@ class Job(models.Model):
# Mark the job as completed # Mark the job as completed
self.status = status self.status = status
self.completed = timezone.now() self.completed = timezone.now()
Job.objects.filter(pk=self.pk).update(status=self.status, completed=self.completed) self.save()
# Handle webhooks # Handle webhooks
self.trigger_webhooks(event=EVENT_JOB_END) self.trigger_webhooks(event=EVENT_JOB_END)

View File

@ -195,8 +195,6 @@ class Report(object):
Run the report and save its results. Each test method will be executed in order. Run the report and save its results. Each test method will be executed in order.
""" """
self.logger.info(f"Running report") self.logger.info(f"Running report")
job.status = JobStatusChoices.STATUS_RUNNING
job.save()
# Perform any post-run tasks # Perform any post-run tasks
self.pre_run() self.pre_run()
@ -218,6 +216,7 @@ class Report(object):
logger.error(f"Exception raised during report execution: {e}") logger.error(f"Exception raised during report execution: {e}")
job.terminate(status=JobStatusChoices.STATUS_ERRORED) job.terminate(status=JobStatusChoices.STATUS_ERRORED)
finally: finally:
job.data = self._results
job.terminate() job.terminate()
# Perform any post-run tasks # Perform any post-run tasks