瀏覽代碼

Use the start time to calculate duration of jobs instead of created time

kkthxbye-code 3 年之前
父節點
當前提交
b35b33e798
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      netbox/extras/models/models.py

+ 6 - 1
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"