Fix display of duration_calculated, display durations less than a minute

This commit is contained in:
Lukáš Kucharczyk 2023-01-04 19:26:01 +01:00
parent 6fe960bc04
commit 12cc9025a0
3 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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" ]

View File

@ -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 (