From af434f0bc00a161462847069ff6a61e809ddd090 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Thu, 12 Nov 2020 14:43:44 +0100 Subject: [PATCH] Fix formatting of /stats --- src/handlebars_util.rs | 8 +++++--- templates/stats.hbs | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/handlebars_util.rs b/src/handlebars_util.rs index f5f5e82..eae09f3 100644 --- a/src/handlebars_util.rs +++ b/src/handlebars_util.rs @@ -14,10 +14,12 @@ pub fn register_helpers(engines: &mut Engines) { handlebars_helper!(pretty_seconds: |secs: u64| { let hours = secs / 60 / 60; let minutes = secs / 60 % 60; - if hours > 0 { - format!("{}h {}m", hours, minutes) - } else { + if hours == 0 { format!("{}m", minutes) + } else if minutes == 0 { + format!("{}h", hours) + } else { + format!("{}h {}m", hours, minutes) } }); engines diff --git a/templates/stats.hbs b/templates/stats.hbs index 7f210a2..a691ac4 100644 --- a/templates/stats.hbs +++ b/templates/stats.hbs @@ -19,6 +19,11 @@ {{#each categories_stats}} {{#if this.last_session_start}}
+

+ Kategori: + {{this.category.name}} + +

Senaste session: {{pretty_datetime this.last_session_start}} @@ -26,11 +31,9 @@ {{pretty_seconds this.secs_last_session}}

- Denna veckan: + Senaste veckan: {{pretty_seconds this.secs_last_week}} -

-

- Denna månaden: + Senaste månaden: {{pretty_seconds this.secs_last_month}}

Andel per timme: