feat: redesigned DB schema with users, work_types, days, events
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user