fix stats

This commit is contained in:
Ben Goldsworthy 2024-12-21 23:23:09 +01:00
parent af4ef2e3c8
commit 2191b0ef8d
Signed by: Rumperuu
SSH key fingerprint: SHA256:e5XfzNOr9UvWpEzyLfw0GtTMZWIFh3NmxH+/qQIi3xE
3 changed files with 39 additions and 10 deletions

View file

@ -20,7 +20,11 @@
</td>
<td>
{{- partial "books/rows/read-dates.html" . -}}
{{- with .date_started -}}
Since {{ time.Format "Jan 2, 2006" . -}}
{{- else -}}
Unknown
{{- end -}}
</td>
</tr>
{{ end }}

View file

@ -8,10 +8,10 @@
<td>{{ .Platforms }}</td>
<td>
{{- if index . "Date Started" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}}
Since {{ time.Format "Jan 2, 2006" ( index . "Date Started" ) -}}
{{- else -}}
Unknown
{{- end -}}&ndash;Unknown
{{- end -}}
</td>
</tr>
{{ end }}

View file

@ -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
-}}
<details class="log-stats">
<summary>Summary</summary>
<div>
<p>Total: {{ $total }}</p>
<p>Total: {{ lang.FormatNumber 0 $total }}</p>
{{- if eq $list_mode "log" -}}
<p>Last 12 months: {{ $this_year_total }}</p>
<p>Last 3 months: {{ $this_quarter_total }}</p>
<p>Last month: {{ $this_month_total }}</p>
<p>Last 12 months: {{ lang.FormatNumber 0 $this_year_total }}</p>
<p>Last 3 months: {{ lang.FormatNumber 0 $this_quarter_total }}</p>
<p>Last month: {{ lang.FormatNumber 0 $this_month_total }}</p>
{{- end -}}
</div>
</details>