From 8c73a51730b5edd088f4d58c5e743ca4c60f928f Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 7 Apr 2021 15:54:43 -0400 Subject: [PATCH] Fix elapsed time on job showing incorrect value - job elapsed time showed 0.0, during and after the job run --- awx/main/models/unified_jobs.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 76a2895bf8..6b9f28941e 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -842,15 +842,16 @@ class UnifiedJob( if 'finished' not in update_fields: update_fields.append('finished') + if self.elapsed is None: + self.elapsed = 0.0 + if 'elapsed' not in update_fields: + update_fields.append('elapsed') + # If we have a start and finished time, and haven't already calculated # out the time that elapsed, do so. - if self.started and self.finished and not self.elapsed: + if self.started and self.finished and self.elapsed == 0.0: td = self.finished - self.started - elapsed = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / (10 ** 6 * 1.0) - else: - elapsed = 0.0 - if self.elapsed != elapsed: - self.elapsed = str(elapsed) + self.elapsed = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / (10 ** 6 * 1.0) if 'elapsed' not in update_fields: update_fields.append('elapsed')