From 7404dd330df522f95bac3130f35fc2bfbafd557e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Thu, 25 Oct 2018 09:23:05 +0200 Subject: [PATCH] Show all deadline lines --- Handler/Graph.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Handler/Graph.hs b/Handler/Graph.hs index 75efd52..ac0cf52 100644 --- a/Handler/Graph.hs +++ b/Handler/Graph.hs @@ -170,7 +170,7 @@ getIndicatorGraphDataR indicatorId = do -- an auxilliary graph let (targetEntries, otherEntries) = partitionEntries (indicatorTargetCondition indicator) filteredEntries - let (scores, timePoints) = addNow theNow $ entriesToPoints (Entity testId test) targetEntries + let (scores', timePoints') = addNow theNow $ entriesToPoints (Entity testId test) targetEntries let (otherScores, otherTimePoints) = addNow theNow $ entriesToPoints (Entity testId test) otherEntries let otherLabel = label <> " (other filtered)" @@ -178,8 +178,15 @@ getIndicatorGraphDataR indicatorId = do -- that's why we need to enforce y range manually if needed -- (x range are not modified this way) let targetValues = map (targetValue . entityVal) $ indicatorEntryTargets indicatorEntry - let maxRange = getBound compare scores targetValues - let minRange = getBound (flip compare) scores targetValues + let maxRange = getBound compare scores' targetValues + let minRange = getBound (flip compare) scores' targetValues + + -- we need to make sure the deadline line is visible + let targetsInTheFuture = + filter (\target -> targetDeadline target > theNow) + $ map entityVal $ indicatorEntryTargets indicatorEntry + let scores = scores' ++ (map (const (last $ impureNonNull scores')) targetsInTheFuture) + let timePoints = timePoints' ++ (map (formatTimestamp . targetDeadline) targetsInTheFuture) -- we return a JSON object required by the C3 library return $ object [