From 2655ed740a8af91a8427f229babe8973dda9708e Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 28 May 2025 09:39:16 +0200 Subject: [PATCH] Fix crash --- tournaments/models/match.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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()