refactor: split handlers.go into 5 files, redesign export month picker, pad calendar rows, improve comments

- Split 1571-line handlers.go into: handlers.go (core), clock.go, settings.go, calendar.go, report.go
- Redesigned export month picker: year navigation + 12-month grid instead of prev/next month
- Fixed calendar last row: pad remaining cells with empty buttons to ensure 7 columns
- Added Go doc comments across all files (dateutil.go, totals.go, store.go, main.go, webhook.go)
This commit is contained in:
2026-06-24 11:33:17 +03:30
parent d8599657f4
commit a8b849f8fd
11 changed files with 1366 additions and 1176 deletions

View File

@@ -1,3 +1,5 @@
// Package bot implements the Telegram bot logic: message routing, time tracking,
// calendar rendering, Excel export, and inline editing of events.
package bot
import (
@@ -6,19 +8,27 @@ import (
"worktimeBot/internal/db"
)
// State represents the current tracking state during daily totals computation.
type State int
const (
// StateIdle indicates no active work session.
StateIdle State = iota
// StateWorking indicates an active work session.
StateWorking
// StateOnBreak indicates an active break session.
StateOnBreak
)
// DailyTotals holds the computed total work and break seconds for a single day.
type DailyTotals struct {
TotalSeconds int64
BreakSeconds int64
}
// ComputeDailyTotals calculates the total work and break time from a list of events.
// It sorts events chronologically, inserts synthetic start/end events when needed,
// and tracks state transitions between idle, working, and on-break.
func ComputeDailyTotals(events []db.Event, minBreakThreshold int64, dayStart, dayEnd int64) DailyTotals {
if len(events) == 0 {
return DailyTotals{}