summaryrefslogtreecommitdiff
path: root/Omni/Task/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Task/Core.hs')
-rw-r--r--Omni/Task/Core.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index e4986c1..07c74fc 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -74,6 +74,20 @@ data TaskProgress = TaskProgress
}
deriving (Show, Eq, Generic)
+data EpicForReview = EpicForReview
+ { epicTask :: Task,
+ epicTotal :: Int,
+ epicCompleted :: Int
+ }
+ deriving (Show, Eq, Generic)
+
+data HumanActionItems = HumanActionItems
+ { failedTasks :: [Task],
+ epicsInReview :: [EpicForReview],
+ humanTasks :: [Task]
+ }
+ deriving (Show, Eq, Generic)
+
data AggregatedMetrics = AggregatedMetrics
{ aggTotalCostCents :: Int,
aggTotalDurationSeconds :: Int,
@@ -1429,6 +1443,35 @@ getInterventionTasks = do
let highRetryIds = [retryTaskId ctx | ctx <- retryContexts, retryAttempt ctx >= 3]
pure [t | t <- allTasks, taskId t `elem` highRetryIds]
+-- | Get all items needing human action
+getHumanActionItems :: IO HumanActionItems
+getHumanActionItems = do
+ allTasks <- loadTasks
+ retryContexts <- getAllRetryContexts
+ let highRetryIds = [retryTaskId ctx | ctx <- retryContexts, retryAttempt ctx >= 3]
+ failed = [t | t <- allTasks, taskId t `elem` highRetryIds]
+ epics = [t | t <- allTasks, taskType t == Epic, taskStatus t /= Done]
+ epicsReady =
+ [ EpicForReview
+ { epicTask = e,
+ epicTotal = total,
+ epicCompleted = completed
+ }
+ | e <- epics,
+ let children = [c | c <- allTasks, taskParent c == Just (taskId e)],
+ let total = length children,
+ total > 0,
+ let completed = length [c | c <- children, taskStatus c == Done],
+ completed == total
+ ]
+ human = [t | t <- allTasks, taskType t == HumanTask, taskStatus t == Open]
+ pure
+ HumanActionItems
+ { failedTasks = failed,
+ epicsInReview = epicsReady,
+ humanTasks = human
+ }
+
-- | Get all retry contexts from the database
getAllRetryContexts :: IO [RetryContext]
getAllRetryContexts =