From c6bb60bbbbabc519ee2015a8ebeb6bbe2fba9732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Tue, 3 Jan 2023 20:23:49 +0100 Subject: [PATCH] Prevent error from empty timestamps --- src/web/tracker/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/web/tracker/models.py b/src/web/tracker/models.py index 30f9811..06da9b9 100644 --- a/src/web/tracker/models.py +++ b/src/web/tracker/models.py @@ -41,7 +41,10 @@ class Session(models.Model): return f"{str(self.purchase)} {str(self.timestamp_start.date())} ({self.total_duration()}{mark})" def calculated_duration(self): - return self.timestamp_end - self.timestamp_start + if self.timestamp_end == None or self.timestamp_start == None: + return 0 + else: + return self.timestamp_end - self.timestamp_start def total_duration(self): return (