forked from filipg/gonito
numbers in graphs are shown with the right precision
This commit is contained in:
parent
1c277f6ad1
commit
c23e28250a
@ -3,7 +3,7 @@ module Handler.Graph where
|
|||||||
import Import
|
import Import
|
||||||
|
|
||||||
import Handler.Tables
|
import Handler.Tables
|
||||||
import Handler.Shared (getMainTest, formatParameter)
|
import Handler.Shared (formatParameter, formatScore)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.List ((!!))
|
import Data.List ((!!))
|
||||||
import Database.Persist.Sql
|
import Database.Persist.Sql
|
||||||
@ -21,6 +21,7 @@ data ParamGraphSeries = ParamGraphSeries Text [(TableEntry, Text, MetricValue)]
|
|||||||
getChallengeParamGraphDataR :: Text -> (Key Test) -> Text -> Handler Value
|
getChallengeParamGraphDataR :: Text -> (Key Test) -> Text -> Handler Value
|
||||||
getChallengeParamGraphDataR challengeName testId paramName = do
|
getChallengeParamGraphDataR challengeName testId paramName = do
|
||||||
(Entity challengeId _) <- runDB $ getBy404 $ UniqueName challengeName
|
(Entity challengeId _) <- runDB $ getBy404 $ UniqueName challengeName
|
||||||
|
test <- runDB $ get404 testId
|
||||||
|
|
||||||
(entries, tests) <- getChallengeSubmissionInfos (const True) challengeId
|
(entries, tests) <- getChallengeSubmissionInfos (const True) challengeId
|
||||||
|
|
||||||
@ -34,11 +35,11 @@ getChallengeParamGraphDataR challengeName testId paramName = do
|
|||||||
|
|
||||||
return $ object [
|
return $ object [
|
||||||
"xs" .= object (map (\(ParamGraphSeries seriesName _) -> (seriesName .= (xSeriesName seriesName))) series),
|
"xs" .= object (map (\(ParamGraphSeries seriesName _) -> (seriesName .= (xSeriesName seriesName))) series),
|
||||||
"columns" .= ((map toYColumn series) ++ (map toXColumn series))
|
"columns" .= ((map (toYColumn $ testPrecision test) series) ++ (map toXColumn series))
|
||||||
]
|
]
|
||||||
toYColumn :: ParamGraphSeries -> [Text]
|
toYColumn :: Maybe Int -> ParamGraphSeries -> [Text]
|
||||||
toYColumn (ParamGraphSeries seriesName items) =
|
toYColumn mPrecision (ParamGraphSeries seriesName items) =
|
||||||
seriesName : (map (\(_,_,v) -> pack $ show v) items)
|
seriesName : (map (\(_,_,v) -> formatScore mPrecision v) items)
|
||||||
|
|
||||||
toXColumn :: ParamGraphSeries -> [Text]
|
toXColumn :: ParamGraphSeries -> [Text]
|
||||||
toXColumn (ParamGraphSeries seriesName items) =
|
toXColumn (ParamGraphSeries seriesName items) =
|
||||||
|
@ -349,6 +349,10 @@ formatTruncatedScore (Just precision) (Just evaluation) = case evaluationScore e
|
|||||||
Just score -> T.pack $ printf "%0.*f" precision score
|
Just score -> T.pack $ printf "%0.*f" precision score
|
||||||
Nothing -> formatFullScore Nothing
|
Nothing -> formatFullScore Nothing
|
||||||
|
|
||||||
|
formatScore :: Maybe Int -> Double -> Text
|
||||||
|
formatScore Nothing = T.pack . show
|
||||||
|
formatScore (Just precision) = T.pack . (printf "%0.*f" precision)
|
||||||
|
|
||||||
formatParameter :: Parameter -> Text
|
formatParameter :: Parameter -> Text
|
||||||
formatParameter param = parameterName param ++ "=" ++ parameterValue param
|
formatParameter param = parameterName param ++ "=" ++ parameterValue param
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user