Permalink
Browse files

Show estimated total and remaining time for todos

  • Loading branch information...
1 parent 63bd4ab commit 5f4836036adc8973d208f79c5946c201ddb791e3 @samstokes committed Sep 16, 2011
Showing with 10 additions and 0 deletions.
  1. +3 −0 Handler/Root.hs
  2. +7 −0 hamlet/tasks.hamlet
View
@@ -60,6 +60,9 @@ getTasksR = maybeAuth >>= getTasksR' where
userTasks userId = selectList [TaskUser ==. userId] [Asc TaskOrder, Desc TaskDoneAt] -- must specify sorts backwards...
taskEstimates taskId = selectList [EstimateTask ==. taskId] []
taskTr (taskId, (task, estimates)) = $(widgetFile "tasks/task-tr")
+ estimatedRemaining :: (Task, [(EstimateId, Estimate)]) -> Int
+ estimatedRemaining (_, []) = 0
+ estimatedRemaining (task, ((_, estimate) : _)) = (estimatePomos estimate - taskPomos task) `max` 0
oneButton :: Text -> YesodoroRoute -> Widget
View
@@ -9,6 +9,13 @@ $else
$forall idAndTaskEstimates <- pending
^{taskTr idAndTaskEstimates}
+ <h3
+ Remaining: #{sum $ map estimatedRemaining $ map snd pending} of
+ $with idsAndEstimates <- map snd $ map snd pending
+ $with firstEstimates <- map snd $ concatMap (take 1) idsAndEstimates
+ $with totalEstimated <- sum $ map estimatePomos firstEstimates
+ \ #{totalEstimated} estimated
+
<form method=POST action=@{TasksR} enctype=#{enctype}
^{taskWidget}
<input type=submit value=Add

0 comments on commit 5f48360

Please sign in to comment.