Skip to content

Commit 0df4d48

Browse files
committed
Show execution_time for running jobs
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 472edc2 commit 0df4d48

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

vulnerabilities/models.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,12 +1959,20 @@ def run_staled(self):
19591959
"""Return True if the execution staled."""
19601960
return self.run_exitcode == 88
19611961

1962+
@property
1963+
def run_running(self):
1964+
"""Return True if the execution is running."""
1965+
return self.status == self.Status.RUNNING
1966+
19621967
@property
19631968
def execution_time(self):
19641969
"""Return the pipeline execution time."""
1965-
if self.run_end_date and self.run_start_date:
1966-
execution_time = (self.run_end_date - self.run_start_date).total_seconds()
1967-
return humanize_time(execution_time)
1970+
if not self.run_start_date or (not self.run_end_date and not self.run_running):
1971+
return
1972+
1973+
end_time = self.run_end_date or timezone.now()
1974+
time_delta = (end_time - self.run_start_date).total_seconds()
1975+
return humanize_time(time_delta)
19681976

19691977
@property
19701978
def pipeline_url(self):

0 commit comments

Comments
 (0)