diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-04 00:05:49 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-04 00:05:49 +0200 |
| commit | c6a9ee27141fd1a57813fcc7f54fe370408bae14 (patch) | |
| tree | 12c8332d0f63f14fce5d9d423743bdee84b28b1c /internal/cli | |
| parent | add16f3c268a7a001259e50ebd1b393ede3cb0a7 (diff) | |
worktime: centralize active category status logic
Diffstat (limited to 'internal/cli')
| -rw-r--r-- | internal/cli/work.go | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/internal/cli/work.go b/internal/cli/work.go index 775a0d7..1f34cf9 100644 --- a/internal/cli/work.go +++ b/internal/cli/work.go @@ -7,7 +7,6 @@ import ( "os" "os/exec" "path/filepath" - "sort" "strconv" "strings" "time" @@ -296,7 +295,7 @@ func newWorkStatusCmd() *cobra.Command { return err } - active := activeCategories(entries) + active := worktime.ActiveCategories(entries) if len(active) == 0 { return printOutput(cmd, "Not logged in.") } @@ -396,33 +395,6 @@ func parseAtOrNow(value string) (time.Time, error) { return timefmt.Parse(value) } -func activeCategories(entries []worktime.Entry) []string { - status := map[string]bool{} - - for _, entry := range entries { - category := strings.TrimSpace(entry.What) - if category == "" { - category = "work" - } - - switch strings.ToLower(strings.TrimSpace(entry.Action)) { - case "login": - status[category] = true - case "logout": - status[category] = false - } - } - - active := make([]string, 0) - for category, isActive := range status { - if isActive { - active = append(active, category) - } - } - sort.Strings(active) - return active -} - func importReportFile(ctx workContext, report io.Reader) (int, error) { return worktime.ImportReport(ctx.dbDir, ctx.host, report) } |
