fix: count work hours in summary even on day-off days

buildMonthlySummary now includes hours for days marked as day-off, matching buildStatusText behavior. Shows "Xh worked (Day Off)" when a day-off day has events.
This commit is contained in:
2026-06-24 20:53:15 +03:30
parent e539350030
commit c9dd076235

View File

@@ -63,25 +63,39 @@ func (h *Handler) buildMonthlySummary(user *db.User, calY, calM int, startStr, e
dayDetails := []string{}
for _, day := range days {
dayLabel := formatDateForCalendar(day.Date, user.Calendar)
if day.IsDayOff {
dayOffCount++
}
events, err := h.DB.EventsForDayByDayID(day.ID)
if err != nil || len(events) == 0 {
if day.IsDayOff {
dayDetails = append(dayDetails, fmt.Sprintf(" %s - Day Off", dayLabel))
}
continue
}
y, m, d := parseGregorianDateKey(day.Date)
dayStart := time.Date(y, time.Month(m), d, 0, 0, 0, 0, loc).Unix()
dayEnd := time.Date(y, time.Month(m), d, 23, 59, 59, 0, loc).Unix()
totals := ComputeDailyTotals(events, day.MinBreakThreshold, dayStart, dayEnd)
dayLabel := formatDateForCalendar(day.Date, user.Calendar)
if totals.TotalSeconds == 0 {
if day.IsDayOff {
dayOffCount++
dayDetails = append(dayDetails, fmt.Sprintf(" %s - Day Off", dayLabel))
} else if totals.TotalSeconds > 0 {
}
continue
}
workDayCount++
totalWork += totals.TotalSeconds
totalBreak += totals.BreakSeconds
dayDetails = append(dayDetails, fmt.Sprintf(" %s - %s worked", dayLabel, formatDuration(totals.TotalSeconds)))
label := fmt.Sprintf(" %s - %s worked", dayLabel, formatDuration(totals.TotalSeconds))
if day.IsDayOff {
label += " (Day Off)"
}
dayDetails = append(dayDetails, label)
}
var b strings.Builder