Fix formatting indicator target values

This commit is contained in:
Filip Graliński 2019-02-22 09:03:43 +01:00
parent ba50789fbe
commit 81167926bf
2 changed files with 6 additions and 5 deletions

View File

@ -189,10 +189,10 @@ prettyIndicatorEntry entry = prettyTestTitle (entityVal $ indicatorEntryTest ent
(entityVal $ indicatorEntryChallenge entry)
formatTargets :: IndicatorEntry -> Text
formatTargets = T.intercalate ", " . (map formatTarget) . indicatorEntryTargets
formatTargets entry = T.intercalate ", " $ (map (formatTarget (testPrecision $ entityVal $ indicatorEntryTest entry))) $ indicatorEntryTargets entry
formatTarget :: Entity Target -> Text
formatTarget (Entity _ target) = (T.pack $ show $ targetValue target) <> " (" <> (T.pack $ formatTime defaultTimeLocale "%Y-%m-%d %H:%M" $ targetDeadline target) ++ ")"
formatTarget :: Maybe Int -> Entity Target -> Text
formatTarget mPrecision (Entity _ target) = (formatScore mPrecision (targetValue target)) <> " (" <> (T.pack $ formatTime defaultTimeLocale "%Y-%m-%d %H:%M" $ targetDeadline target) ++ ")"
indicatorStatusCell :: Maybe (Entity User) -> Table.Table App IndicatorEntry
indicatorStatusCell mUser = Table.widget "" (indicatorStatusCellWidget mUser)

View File

@ -247,13 +247,13 @@ targetsToLines theNow indicator = object [
"y" .= object [
"lines" .= map (\target -> object [
"value" .= (targetValue $ entityVal target),
"text" .= formatTarget target
"text" .= formatTarget mPrecision target
]) targets
],
"x" .= object [
"lines" .= ((map (\target -> object [
"value" .= (formatTimestamp $ targetDeadline $ entityVal target),
"text" .= formatTarget target
"text" .= formatTarget mPrecision target
]) targets)
++ [object [
"value" .= formatTimestamp theNow,
@ -262,6 +262,7 @@ targetsToLines theNow indicator = object [
]
]
where targets = indicatorEntryTargets indicator
mPrecision = testPrecision $ entityVal $ indicatorEntryTest indicator
getBound :: (a -> a -> Ordering) -> [a] -> [a] -> Maybe a
getBound _ [] _ = Nothing