summaryrefslogtreecommitdiff
path: root/Omni/Task
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-29 22:09:56 -0500
committerBen Sima <ben@bensima.com>2025-11-29 22:09:56 -0500
commita5180facf2375cf629ce7d90f851e6c667f66197 (patch)
tree57fdbb26e485940b9989b2b747fb799817c06f1b /Omni/Task
parentf7b875b650e791f604fcf35e04f06310352cb352 (diff)
Add time range filter to homepage Task Status section
The build and tests pass with no errors. The time range filter feature f **Implementation summary:** - Route accepts `?range=today|week|month|all` query param - `TimeRange` type with `Today`, `Week`, `Month`, `AllTime` variants - `homeHandler` filters both tasks and activities by time range - Toggle buttons rendered with `timeFilterBtn` helper - Full CSS styling in `timeFilterStyles` with dark mode support - Default selection: "All Time" Task-Id: t-180
Diffstat (limited to 'Omni/Task')
-rw-r--r--Omni/Task/Core.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 722e696..d64d607 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -1133,6 +1133,43 @@ getAllDescendants allTasks parentId =
let children = filter (maybe False (`matchesId` parentId) <. taskParent) allTasks
in children ++ concatMap (getAllDescendants allTasks <. taskId) children
+computeTaskStatsFromList :: [Task] -> TaskStats
+computeTaskStatsFromList tasks =
+ let total = length tasks
+ draft = length [t | t <- tasks, taskStatus t == Draft]
+ open = length [t | t <- tasks, taskStatus t == Open]
+ inProg = length [t | t <- tasks, taskStatus t == InProgress]
+ review = length [t | t <- tasks, taskStatus t == Review]
+ approved = length [t | t <- tasks, taskStatus t == Approved]
+ done = length [t | t <- tasks, taskStatus t == Done]
+ epics = length [t | t <- tasks, taskType t == Epic]
+ readyCount = open + inProg
+ blockedCount = 0
+ byPriority =
+ [ (P0, length [t | t <- tasks, taskPriority t == P0]),
+ (P1, length [t | t <- tasks, taskPriority t == P1]),
+ (P2, length [t | t <- tasks, taskPriority t == P2]),
+ (P3, length [t | t <- tasks, taskPriority t == P3]),
+ (P4, length [t | t <- tasks, taskPriority t == P4])
+ ]
+ namespaces = mapMaybe taskNamespace tasks
+ uniqueNs = List.nub namespaces
+ byNamespace = [(ns, length [t | t <- tasks, taskNamespace t == Just ns]) | ns <- uniqueNs]
+ in TaskStats
+ { totalTasks = total,
+ draftTasks = draft,
+ openTasks = open,
+ inProgressTasks = inProg,
+ reviewTasks = review,
+ approvedTasks = approved,
+ doneTasks = done,
+ totalEpics = epics,
+ readyTasks = readyCount,
+ blockedTasks = blockedCount,
+ tasksByPriority = byPriority,
+ tasksByNamespace = byNamespace
+ }
+
showTaskStats :: Maybe Text -> IO ()
showTaskStats maybeEpicId = do
stats <- getTaskStats maybeEpicId