diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-29 20:40:25 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-29 20:40:25 -0500 |
| commit | f7b875b650e791f604fcf35e04f06310352cb352 (patch) | |
| tree | 142e2fb040961f69a797dec9c2bfc52bf05aaed3 /Omni/Task | |
| parent | 926018e989cba4286c98eb2682e51ef32b2ee0c8 (diff) | |
Add cost and duration metrics to homepage Task Status section
The implementation is complete. The build passed with `bild --test
Omni/
**Summary of changes:**
1. **Omni/Task/Core.hs**: Added `getGlobalAggregatedMetrics ::
IO Aggreg
2. **Omni/Jr/Web.hs**:
- Updated `HomePage` data type to include `AggregatedMetrics`
paramet - Updated `homeHandler` to fetch global metrics via
`getGlobalAggrega - Updated `ToHtml HomePage` instance to add
two new cards: "Cost" (fo - Added helper functions `metricCard`,
`formatCost`, and `formatDurat
3. **Omni/Jr/Web/Style.hs**: Added `badge-neutral` CSS styling
(gray bor
Task-Id: t-179
Diffstat (limited to 'Omni/Task')
| -rw-r--r-- | Omni/Task/Core.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 773a01f..722e696 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -1320,6 +1320,28 @@ getAggregatedMetrics epicId = do (Just start, Just end) -> floor (diffUTCTime end start) _ -> 0 +-- | Get aggregated metrics for all tasks globally (not scoped to an epic) +getGlobalAggregatedMetrics :: IO AggregatedMetrics +getGlobalAggregatedMetrics = do + allTasks <- loadTasks + let completedCount = length [t | t <- allTasks, taskStatus t == Done] + taskIds = map taskId allTasks + activities <- concat </ traverse getActivitiesForTask taskIds + let totalCost = sum [c | act <- activities, Just c <- [activityCostCents act]] + totalTokens = sum [t | act <- activities, Just t <- [activityTokensUsed act]] + totalDuration = sum [calcDuration act | act <- activities] + pure + AggregatedMetrics + { aggTotalCostCents = totalCost, + aggTotalDurationSeconds = totalDuration, + aggCompletedTasks = completedCount, + aggTotalTokens = totalTokens + } + where + calcDuration act = case (activityStartedAt act, activityCompletedAt act) of + (Just start, Just end) -> floor (diffUTCTime end start) + _ -> 0 + -- | Get tasks with unmet blocking dependencies (not ready, not done) getBlockedTasks :: IO [Task] getBlockedTasks = do |
