fix: potential null query
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Evan Reichard 2024-01-24 18:43:33 -05:00
parent 35ca021649
commit e33a64db96
3 changed files with 50 additions and 47 deletions

View File

@ -314,22 +314,22 @@ SELECT
CAST(SUM(total_words_read) AS INTEGER) AS total_words_read, CAST(SUM(total_words_read) AS INTEGER) AS total_words_read,
CAST(SUM(total_time_seconds) AS INTEGER) AS total_seconds, 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, AS total_wpm,
CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read, CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read,
CAST(SUM(yearly_time_seconds) AS INTEGER) AS yearly_seconds, 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, AS yearly_wpm,
CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read, CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read,
CAST(SUM(monthly_time_seconds) AS INTEGER) AS monthly_seconds, 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, AS monthly_wpm,
CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read, CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read,
CAST(SUM(weekly_time_seconds) AS INTEGER) AS weekly_seconds, 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 AS weekly_wpm
FROM document_user_statistics FROM document_user_statistics

View File

@ -977,22 +977,22 @@ SELECT
CAST(SUM(total_words_read) AS INTEGER) AS total_words_read, CAST(SUM(total_words_read) AS INTEGER) AS total_words_read,
CAST(SUM(total_time_seconds) AS INTEGER) AS total_seconds, 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, AS total_wpm,
CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read, CAST(SUM(yearly_words_read) AS INTEGER) AS yearly_words_read,
CAST(SUM(yearly_time_seconds) AS INTEGER) AS yearly_seconds, 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, AS yearly_wpm,
CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read, CAST(SUM(monthly_words_read) AS INTEGER) AS monthly_words_read,
CAST(SUM(monthly_time_seconds) AS INTEGER) AS monthly_seconds, 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, AS monthly_wpm,
CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read, CAST(SUM(weekly_words_read) AS INTEGER) AS weekly_words_read,
CAST(SUM(weekly_time_seconds) AS INTEGER) AS weekly_seconds, 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 AS weekly_wpm
FROM document_user_statistics FROM document_user_statistics

View File

@ -1,6 +1,8 @@
{{template "base" .}} {{define "title"}}Home{{end}} {{define "header"}} {{template "base" .}}
<a href="./">Home</a> {{define "title"}}Home{{end}}
{{end}} {{define "content"}} {{define "header"}}<a href="./">Home</a>{{end}}
{{define "content"}}
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<div class="w-full"> <div class="w-full">
<div <div
@ -159,32 +161,7 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"> <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
{{ 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
)
}}
</div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{{ range $item := .Data.Streaks }} {{ range $item := .Data.Streaks }}
<div class="w-full"> <div class="w-full">
<div <div
@ -193,8 +170,11 @@
<p <p
class="text-sm font-semibold text-gray-700 border-b border-gray-200 w-max dark:text-white dark:border-gray-500" class="text-sm font-semibold text-gray-700 border-b border-gray-200 w-max dark:text-white dark:border-gray-500"
> >
{{ if eq $item.Window "WEEK" }} Weekly Read Streak {{ else }} Daily {{ if eq $item.Window "WEEK" }}
Read Streak {{ end }} Weekly Read Streak
{{ else }}
Daily Read Streak
{{ end }}
</p> </p>
<div class="flex items-end my-6 space-x-2"> <div class="flex items-end my-6 space-x-2">
<p class="text-5xl font-bold text-black dark:text-white"> <p class="text-5xl font-bold text-black dark:text-white">
@ -211,19 +191,19 @@
Current Daily Streak {{ end }} Current Daily Streak {{ end }}
</p> </p>
<div class="flex items-end text-sm text-gray-400"> <div class="flex items-end text-sm text-gray-400">
{{ $item.CurrentStreakStartDate }} ➞ {{ {{ $item.CurrentStreakStartDate }} ➞ {{ $item.CurrentStreakEndDate }}
$item.CurrentStreakEndDate }}
</div> </div>
</div> </div>
<div class="flex items-end font-bold"> <div class="flex items-end font-bold">{{ $item.CurrentStreak }}</div>
{{ $item.CurrentStreak }}
</div>
</div> </div>
<div class="flex items-center justify-between pb-2 mb-2 text-sm"> <div class="flex items-center justify-between pb-2 mb-2 text-sm">
<div> <div>
<p> <p>
{{ if eq $item.Window "WEEK" }} Best Weekly Streak {{ else }} {{ if eq $item.Window "WEEK" }}
Best Daily Streak {{ end }} Best Weekly Streak
{{ else }}
Best Daily Streak
{{ end }}
</p> </p>
<div class="flex items-end text-sm text-gray-400"> <div class="flex items-end text-sm text-gray-400">
{{ $item.MaxStreakStartDate }} ➞ {{ $item.MaxStreakEndDate }} {{ $item.MaxStreakStartDate }} ➞ {{ $item.MaxStreakEndDate }}
@ -235,6 +215,29 @@
</div> </div>
</div> </div>
{{ end }} {{ end }}
</div>
{{end}} <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{{ 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
)
}}
</div>
</div> </div>
{{end}}