diff --git a/tournaments/models/match.py b/tournaments/models/match.py index c0f22b2..d901e40 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -348,6 +348,15 @@ class Match(SideStoreModel): return format_seconds(self.smart_time_played()) def smart_time_played(self): + if self.start_date: + if self.end_date: + return self.__smart_duration() + else: + return (timezone.now() - self.start_date).total_seconds() + else: + return 0 + + def __smart_duration(self): seconds = (self.end_date - self.start_date).total_seconds() average_duration = self.average_seconds_duration()