From 1d2c2ca78f8073944f2781abd156a66e457bf772 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sat, 30 Nov 2019 11:25:53 +0100 Subject: [PATCH] Variant information reachable from query results --- Handler/Query.hs | 7 ++++--- Handler/Tables.hs | 5 +++++ templates/variant-status.hamlet | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 templates/variant-status.hamlet diff --git a/Handler/Query.hs b/Handler/Query.hs index b8ab176..dfb8df2 100644 --- a/Handler/Query.hs +++ b/Handler/Query.hs @@ -100,9 +100,10 @@ getViewVariantR variantId = do let theSubmissionId = variantSubmission variant theSubmission <- runDB $ get404 theSubmissionId - ([entry], tests) <- runDB $ getChallengeSubmissionInfos (\e -> entityKey e == theSubmissionId) - (\e -> entityKey e == variantId) - (submissionChallenge theSubmission) + ([entry], tests') <- runDB $ getChallengeSubmissionInfos (\e -> entityKey e == theSubmissionId) + (\e -> entityKey e == variantId) + (submissionChallenge theSubmission) + let tests = sortBy (flip testComparator) tests' if submissionIsPublic theSubmission || Just (submissionSubmitter theSubmission) == (entityKey <$> mauthId) then diff --git a/Handler/Tables.hs b/Handler/Tables.hs index 1137ba6..6942b13 100644 --- a/Handler/Tables.hs +++ b/Handler/Tables.hs @@ -82,6 +82,11 @@ variantTable paramNames tests = mempty ++ Table.int "#" tableEntryRank ++ mconcat (map paramExtractor paramNames) ++ mconcat (map (\e@(Entity _ t) -> resultCell t (extractScore $ getTestReference e)) tests) + ++ Table.widget "" variantStatusCellWidget + +variantStatusCellWidget :: TableEntry -> WidgetFor App () +variantStatusCellWidget entry = $(widgetFile "variant-status") + where theVariantId = entityKey $ tableEntryVariant entry paramExtractor :: Text -> Table App TableEntry paramExtractor paramName = Table.text paramName (\entry -> diff --git a/templates/variant-status.hamlet b/templates/variant-status.hamlet new file mode 100644 index 0000000..fdcf882 --- /dev/null +++ b/templates/variant-status.hamlet @@ -0,0 +1,2 @@ + +