From bc5074a52b81e85245d628aebd23eb65c496c35a Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 1 Apr 2023 13:07:23 +0200 Subject: fix division by zero for profile page Now that round_to_seconds can actually return 0, we need to catch this case. --- fietsboek/views/profile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fietsboek/views/profile.py b/fietsboek/views/profile.py index 81ec16d..e73df42 100644 --- a/fietsboek/views/profile.py +++ b/fietsboek/views/profile.py @@ -97,6 +97,8 @@ class CumulativeStats: @property def avg_speed(self) -> float: """Average speed, in m/s.""" + if not self.moving_time: + return 0.0 return self.length / self.moving_time.total_seconds() -- cgit v1.2.3