feat: redesigned DB schema with users, work_types, days, events

This commit is contained in:
2026-06-24 00:36:16 +03:30
parent 8616ed0867
commit 2970b7d3fc
6 changed files with 904 additions and 242 deletions

View File

@@ -20,7 +20,7 @@ type DailyTotals struct {
PairCount int
}
func ComputeDailyTotals(events []db.Event) DailyTotals {
func ComputeDailyTotals(events []db.Event, minBreakThreshold int64) DailyTotals {
if len(events) == 0 {
return DailyTotals{}
}
@@ -43,9 +43,13 @@ func ComputeDailyTotals(events []db.Event) DailyTotals {
workStart = e.OccurredAt
state = StateWorking
case StateOnBreak:
breakTotal += e.OccurredAt - breakStart
breakStart = 0
workStart = e.OccurredAt
breakDuration := e.OccurredAt - breakStart
if minBreakThreshold > 0 && breakDuration <= minBreakThreshold {
workStart = breakStart
} else {
breakTotal += breakDuration
workStart = e.OccurredAt
}
state = StateWorking
}
case "out":