From 2191b0ef8d08507b23df5ea3808738153025de00 Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Sat, 21 Dec 2024 23:23:09 +0100 Subject: [PATCH] fix stats --- layouts/partials/books/table-body.html | 6 +++- layouts/partials/games/table-body.html | 4 +-- layouts/partials/stats.html | 39 +++++++++++++++++++++----- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/layouts/partials/books/table-body.html b/layouts/partials/books/table-body.html index 39d52e4..9fe5ffe 100644 --- a/layouts/partials/books/table-body.html +++ b/layouts/partials/books/table-body.html @@ -20,7 +20,11 @@ - {{- partial "books/rows/read-dates.html" . -}} + {{- with .date_started -}} + Since {{ time.Format "Jan 2, 2006" . -}} + {{- else -}} + Unknown + {{- end -}} {{ end }} diff --git a/layouts/partials/games/table-body.html b/layouts/partials/games/table-body.html index e166055..4d76fa0 100644 --- a/layouts/partials/games/table-body.html +++ b/layouts/partials/games/table-body.html @@ -8,10 +8,10 @@ {{ .Platforms }} {{- if index . "Date Started" -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}} + Since {{ time.Format "Jan 2, 2006" ( index . "Date Started" ) -}} {{- else -}} Unknown - {{- end -}}–Unknown + {{- end -}} {{ end }} diff --git a/layouts/partials/stats.html b/layouts/partials/stats.html index a6e5e06..4c2da90 100644 --- a/layouts/partials/stats.html +++ b/layouts/partials/stats.html @@ -7,19 +7,44 @@ {{- $today := time.Now -}} - {{- $this_year_total := len ( where ( where $log_file "date_finished" "gt" ( ( $today.AddDate -1 0 0 ).Format "2006-01-02" ) ) "date_finished" "lt" "2024-12-31" ) -}} - {{- $this_quarter_total := len ( where ( where $log_file "date_finished" "gt" ( ( $today.AddDate 0 -3 0 ).Format "2006-01-02" ) ) "date_finished" "lt" "2024-09-30" ) -}} - {{- $this_month_total := len ( where ( where $log_file "date_finished" "gt" ( ( $today.AddDate 0 -1 0 ).Format "2006-01-02" ) ) "date_finished" "lt" "2024-07-31" ) -}} + {{- + $this_year_total := ( + where ( + where $log_file "date_finished" "gt" ( + ( $today.AddDate -1 0 0 ).Format "2006-01-02" + ) + ) "date_finished" "lt" ( $today.Format "2006-01-02" ) + ) | len + -}} + + {{- + $this_quarter_total := ( + where ( + where $log_file "date_finished" "gt" ( + ( $today.AddDate 0 -3 0 ).Format "2006-01-02" + ) + ) "date_finished" "lt" ( $today.Format "2006-01-02" ) + ) | len + -}} + {{- + $this_month_total := ( + where ( + where $log_file "date_finished" "gt" ( + ( $today.AddDate 0 -1 0 ).Format "2006-01-02" + ) + ) "date_finished" "lt" ( $today.Format "2006-01-02" ) + ) | len + -}}
Summary
-

Total: {{ $total }}

+

Total: {{ lang.FormatNumber 0 $total }}

{{- if eq $list_mode "log" -}} -

Last 12 months: {{ $this_year_total }}

-

Last 3 months: {{ $this_quarter_total }}

-

Last month: {{ $this_month_total }}

+

Last 12 months: {{ lang.FormatNumber 0 $this_year_total }}

+

Last 3 months: {{ lang.FormatNumber 0 $this_quarter_total }}

+

Last month: {{ lang.FormatNumber 0 $this_month_total }}

{{- end -}}