From bfcf3500ad3b462c90b6930c6cea637ec0e8d06b Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 14 Jul 2024 19:06:47 +0200 Subject: [PATCH] Fixes displayed duration --- tournaments/models/match.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index 814b3cf..f3c0274 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -125,7 +125,21 @@ class Match(models.Model): if self.end_date: return (self.end_date - self.start_date).total_seconds() else: - return (timezone.now() - self.start_date).total_seconds() + current = (timezone.now() - self.start_date).total_seconds() + if self.total_number_of_games() > 0 and current < self.average_seconds_duration() * 4: + return current + elif self.total_number_of_games() == 0 and current < 4 * 60 * 60: + return current + else: + return None + # print(current) + # print(self.average_seconds_duration()) + # print('*******') + # if current < self.average_seconds_duration() * 4: + # return current + # else: + # return None + # return (timezone.now() - self.start_date).total_seconds() else: return 0