From 13f7678a9fd092ac20eec10e4d2196f5bd1ae107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20B=C3=BCtow?= <1224732+snonux@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:40:56 +0300 Subject: Add cell navigation, editor hotkey, stats and filter --- internal/task/stats.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 internal/task/stats.go (limited to 'internal/task/stats.go') diff --git a/internal/task/stats.go b/internal/task/stats.go new file mode 100644 index 0000000..c516249 --- /dev/null +++ b/internal/task/stats.go @@ -0,0 +1,40 @@ +package task + +import "time" + +// TotalTasks returns the number of tasks provided. +func TotalTasks(tasks []Task) int { + return len(tasks) +} + +// InProgressTasks returns the number of tasks that have been started and are not completed. +func InProgressTasks(tasks []Task) int { + count := 0 + for _, t := range tasks { + if t.Status == "completed" { + continue + } + if t.Start != "" { + count++ + } + } + return count +} + +// DueTasks returns the number of tasks with a due date that is not in the future. +func DueTasks(tasks []Task, now time.Time) int { + count := 0 + for _, t := range tasks { + if t.Status == "completed" || t.Due == "" { + continue + } + ts, err := time.Parse("20060102T150405Z", t.Due) + if err != nil { + continue + } + if !ts.After(now) { + count++ + } + } + return count +} -- cgit v1.2.3