aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-04-01 13:07:23 +0200
committerDaniel Schadt <kingdread@gmx.de>2023-04-01 13:07:23 +0200
commitbc5074a52b81e85245d628aebd23eb65c496c35a (patch)
tree7b2e1b1cee90884669aa598e20813e15a99c4428
parent982d6c8cd5ba6ade04683e5699fc9fc170e4c109 (diff)
downloadfietsboek-bc5074a52b81e85245d628aebd23eb65c496c35a.tar.gz
fietsboek-bc5074a52b81e85245d628aebd23eb65c496c35a.tar.bz2
fietsboek-bc5074a52b81e85245d628aebd23eb65c496c35a.zip
fix division by zero for profile page
Now that round_to_seconds can actually return 0, we need to catch this case.
-rw-r--r--fietsboek/views/profile.py2
1 files changed, 2 insertions, 0 deletions
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()