From 12cc9025a0efb586b47f53303014e0d4ae9fe2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 4 Jan 2023 19:26:01 +0100 Subject: [PATCH] Fix display of duration_calculated, display durations less than a minute --- CHANGELOG.md | 1 + Dockerfile | 2 +- src/web/tracker/models.py | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e2acb..a1605a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Unreleased +* Fix display of duration_calculated, display durations less than a minute * Make the "Finish now?" button on session list work * Hide navigation bar items if there are no games/purchases/sessions * Set default version to "git-main" to indicate development environment diff --git a/Dockerfile b/Dockerfile index 5b2f517..e3c0c84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ COPY entrypoint.sh / RUN chmod +x /entrypoint.sh USER timetracker EXPOSE 8000 -ENV VERSION_NUMBER 0.1.0-14-g61d2e65 +ENV VERSION_NUMBER 0.1.0-15-g6fe960b ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/src/web/tracker/models.py b/src/web/tracker/models.py index a129c72..3e1692c 100644 --- a/src/web/tracker/models.py +++ b/src/web/tracker/models.py @@ -60,10 +60,13 @@ class Session(models.Model): if seconds == 0: return seconds hours, remainder = divmod(seconds, 3600) - minutes = remainder % 60 - hour_string = f"{int(hours)}h" if hours != 0 else "" - minute_string = f"{int(minutes)}m" if minutes != 0 else "" - return f"{hour_string}{minute_string}" + minutes = remainder // 60 + if hours == 0 and minutes == 0: + return "less than a minute" + else: + hour_string = f"{int(hours)}h" if hours != 0 else "" + minute_string = f"{int(minutes)}m" if minutes != 0 else "" + return f"{hour_string}{minute_string}" def duration_any(self): return (