summaryrefslogtreecommitdiff
path: root/internal/database
diff options
context:
space:
mode:
Diffstat (limited to 'internal/database')
-rw-r--r--internal/database/queries.sql29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/database/queries.sql b/internal/database/queries.sql
index 3a644b8..c68cdad 100644
--- a/internal/database/queries.sql
+++ b/internal/database/queries.sql
@@ -284,3 +284,32 @@ where p.id = @project_id
and te.start_time <= @end_time
and te.end_time is not null
order by te.start_time;
+
+-- name: GetTodaySummary :one
+select
+ cast(sum(
+ case
+ when te.end_time is null then
+ (julianday('now', 'utc') - julianday(te.start_time)) * 24 * 60 * 60
+ else
+ (julianday(te.end_time) - julianday(te.start_time)) * 24 * 60 * 60
+ end
+ ) as integer) as total_seconds
+from time_entry te
+where date(te.start_time) = date('now');
+
+-- name: GetRecentTimeEntries :many
+select * from time_entry
+order by start_time desc
+limit @limit_count;
+
+-- name: UpdateActiveTimerDescription :exec
+update time_entry
+set description = @description
+where id = (
+ select id
+ from time_entry
+ where end_time is null
+ order by start_time desc
+ limit 1
+);