Add rank for variants

This commit is contained in:
Filip Gralinski 2021-02-15 21:39:06 +01:00
parent fea7dabbd4
commit 3705eb1e74

View File

@ -57,6 +57,7 @@ import Handler.ShowChallenge
data VariantView = VariantView { data VariantView = VariantView {
variantViewId :: Int64, variantViewId :: Int64,
variantViewName :: Text, variantViewName :: Text,
variantViewRank :: Int,
variantViewEvaluations :: [EvaluationView], variantViewEvaluations :: [EvaluationView],
variantViewParams :: [Parameter] variantViewParams :: [Parameter]
} }
@ -82,6 +83,7 @@ instance ToJSON VariantView where
toJSON entry = object toJSON entry = object
[ "id" .= variantViewId entry, [ "id" .= variantViewId entry,
"name" .= variantViewName entry, "name" .= variantViewName entry,
"rank" .= variantViewRank entry,
"evaluations" .= variantViewEvaluations entry, "evaluations" .= variantViewEvaluations entry,
"params" .= variantViewParams entry "params" .= variantViewParams entry
] ]
@ -97,6 +99,7 @@ instance ToSchema VariantView where
& properties .~ & properties .~
fromList [ ("id", intSchema), fromList [ ("id", intSchema),
("name", stringSchema), ("name", stringSchema),
("rank", intSchema),
("evaluations", evaluationsSchema), ("evaluations", evaluationsSchema),
("params", paramsSchema) ("params", paramsSchema)
] ]
@ -291,6 +294,7 @@ toQueryResultView fsi = do
VariantView { VariantView {
variantViewId = fromSqlKey $ entityKey $ tableEntryVariant entry, variantViewId = fromSqlKey $ entityKey $ tableEntryVariant entry,
variantViewName = variantName $ entityVal $ tableEntryVariant entry, variantViewName = variantName $ entityVal $ tableEntryVariant entry,
variantViewRank = tableEntryRank entry,
variantViewEvaluations = catMaybes $ Import.map (convertEvaluationToView $ tableEntryMapping entry) tests, variantViewEvaluations = catMaybes $ Import.map (convertEvaluationToView $ tableEntryMapping entry) tests,
variantViewParams = Import.map entityVal $ tableEntryParams entry variantViewParams = Import.map entityVal $ tableEntryParams entry