From b35b33e7986a72a9cbdadfbc09dbfd72a64518a2 Mon Sep 17 00:00:00 2001 From: kkthxbye-code Date: Thu, 22 Dec 2022 12:28:30 +0100 Subject: [PATCH] Use the start time to calculate duration of jobs instead of created time --- netbox/extras/models/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index 6a60458e2..699baa11b 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -651,7 +651,12 @@ class JobResult(models.Model): if not self.completed: return None - duration = self.completed - self.created + start_time = self.started or self.created + + if not start_time: + return None + + duration = self.completed - start_time minutes, seconds = divmod(duration.total_seconds(), 60) return f"{int(minutes)} minutes, {seconds:.2f} seconds"