Use playbook.updated instead of "now" for calculating duration

Using now() to calculate the duration was not accurate.
If a playbook had never ended, it would show that a playbook ran
yesterday for >40k seconds and keep growing, for example.
playbook.updated is the next best thing we've got so let's use that.

Change-Id: I66c6073879d716586425e0a84f3da1dcbf04c7e8
This commit is contained in:
David Moreau Simard 2018-10-16 09:27:28 -04:00
parent 031e757979
commit 8f4ed9e541
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
1 changed files with 1 additions and 2 deletions

View File

@ -20,7 +20,6 @@ import json
import logging
import zlib
from django.utils import timezone
from rest_framework import serializers
from ara.api import models
@ -70,7 +69,7 @@ class DurationSerializer(serializers.ModelSerializer):
@staticmethod
def get_duration(obj):
if obj.ended is None:
return timezone.now() - obj.started
return obj.updated - obj.started
return obj.ended - obj.started