diff --git a/database/query.sql b/database/query.sql index 681baca..c721c1e 100644 --- a/database/query.sql +++ b/database/query.sql @@ -314,22 +314,22 @@ SELECT CAST(SUM(total_words_read) AS INTEGER) AS total_words_read, CAST(SUM(total_time_seconds) AS INTEGER) AS total_seconds, - ROUND(CAST(SUM(total_words_read) AS REAL) / (SUM(total_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(total_words_read) AS REAL) / (SUM(total_time_seconds) / 60.0), 0.0), 2) AS total_wpm, CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read, CAST(SUM(yearly_time_seconds) AS INTEGER) AS yearly_seconds, - ROUND(CAST(SUM(yearly_words_read) AS REAL) / (SUM(yearly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(yearly_words_read) AS REAL) / (SUM(yearly_time_seconds) / 60.0), 0.0), 2) AS yearly_wpm, CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read, CAST(SUM(monthly_time_seconds) AS INTEGER) AS monthly_seconds, - ROUND(CAST(SUM(monthly_words_read) AS REAL) / (SUM(monthly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(monthly_words_read) AS REAL) / (SUM(monthly_time_seconds) / 60.0), 0.0), 2) AS monthly_wpm, CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read, CAST(SUM(weekly_time_seconds) AS INTEGER) AS weekly_seconds, - ROUND(CAST(SUM(weekly_words_read) AS REAL) / (SUM(weekly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(weekly_words_read) AS REAL) / (SUM(weekly_time_seconds) / 60.0), 0.0), 2) AS weekly_wpm FROM document_user_statistics diff --git a/database/query.sql.go b/database/query.sql.go index c341da3..a2da4fb 100644 --- a/database/query.sql.go +++ b/database/query.sql.go @@ -977,22 +977,22 @@ SELECT CAST(SUM(total_words_read) AS INTEGER) AS total_words_read, CAST(SUM(total_time_seconds) AS INTEGER) AS total_seconds, - ROUND(CAST(SUM(total_words_read) AS REAL) / (SUM(total_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(total_words_read) AS REAL) / (SUM(total_time_seconds) / 60.0), 0.0), 2) AS total_wpm, CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read, CAST(SUM(yearly_time_seconds) AS INTEGER) AS yearly_seconds, - ROUND(CAST(SUM(yearly_words_read) AS REAL) / (SUM(yearly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(yearly_words_read) AS REAL) / (SUM(yearly_time_seconds) / 60.0), 0.0), 2) AS yearly_wpm, CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read, CAST(SUM(monthly_time_seconds) AS INTEGER) AS monthly_seconds, - ROUND(CAST(SUM(monthly_words_read) AS REAL) / (SUM(monthly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(monthly_words_read) AS REAL) / (SUM(monthly_time_seconds) / 60.0), 0.0), 2) AS monthly_wpm, CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read, CAST(SUM(weekly_time_seconds) AS INTEGER) AS weekly_seconds, - ROUND(CAST(SUM(weekly_words_read) AS REAL) / (SUM(weekly_time_seconds) / 60.0), 2) + ROUND(COALESCE(CAST(SUM(weekly_words_read) AS REAL) / (SUM(weekly_time_seconds) / 60.0), 0.0), 2) AS weekly_wpm FROM document_user_statistics diff --git a/templates/pages/home.html b/templates/pages/home.html index 4971e98..7bba5c4 100644 --- a/templates/pages/home.html +++ b/templates/pages/home.html @@ -1,6 +1,8 @@ -{{template "base" .}} {{define "title"}}Home{{end}} {{define "header"}} -Home -{{end}} {{define "content"}} +{{template "base" .}} +{{define "title"}}Home{{end}} +{{define "header"}}Home{{end}} + +{{define "content"}}
-
- {{ template "component/leaderboard-card" ( - dict - "Name" "WPM" - "Data" .Data.UserStatistics.WPM - ) - }} - - {{ template "component/leaderboard-card" ( - dict - "Name" "Duration" - "Data" .Data.UserStatistics.Duration - ) - }} - - {{ template "component/leaderboard-card" ( - dict - "Name" "Words" - "Data" .Data.UserStatistics.Words - ) - }} - - -
- -
+
{{ range $item := .Data.Streaks }}
- {{ if eq $item.Window "WEEK" }} Weekly Read Streak {{ else }} Daily - Read Streak {{ end }} + {{ if eq $item.Window "WEEK" }} + Weekly Read Streak + {{ else }} + Daily Read Streak + {{ end }}

@@ -211,19 +191,19 @@ Current Daily Streak {{ end }}

- {{ $item.CurrentStreakStartDate }} ➞ {{ - $item.CurrentStreakEndDate }} + {{ $item.CurrentStreakStartDate }} ➞ {{ $item.CurrentStreakEndDate }}
-
- {{ $item.CurrentStreak }} -
+
{{ $item.CurrentStreak }}

- {{ if eq $item.Window "WEEK" }} Best Weekly Streak {{ else }} - Best Daily Streak {{ end }} + {{ if eq $item.Window "WEEK" }} + Best Weekly Streak + {{ else }} + Best Daily Streak + {{ end }}

{{ $item.MaxStreakStartDate }} ➞ {{ $item.MaxStreakEndDate }} @@ -235,6 +215,29 @@
{{ end }} +
- {{end}} +
+ {{ template "component/leaderboard-card" ( + dict + "Name" "WPM" + "Data" .Data.UserStatistics.WPM + ) + }} + + {{ template "component/leaderboard-card" ( + dict + "Name" "Duration" + "Data" .Data.UserStatistics.Duration + ) + }} + + {{ template "component/leaderboard-card" ( + dict + "Name" "Words" + "Data" .Data.UserStatistics.Words + ) + }} +
+{{end}}