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>
<td> <td>
{{- partial "books/rows/read-dates.html" . -}} {{- with .date_started -}}
Since {{ time.Format "Jan 2, 2006" . -}}
{{- else -}}
Unknown
{{- end -}}
</td> </td>
</tr> </tr>
{{ end }} {{ end }}

View file

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

View file

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