From 9fe07335cd0dfd60a0ada56740e3d30c676f4ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Mon, 16 Dec 2019 17:07:38 +0100 Subject: [PATCH] Add more utils for presentations --- Handler/Presentation.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Handler/Presentation.hs b/Handler/Presentation.hs index 6beb58a..1a68e6d 100644 --- a/Handler/Presentation.hs +++ b/Handler/Presentation.hs @@ -78,10 +78,15 @@ getPresentationDATeCH2017R = do getSampleLeaderboard :: Text -> HandlerFor App (WidgetFor App ()) -getSampleLeaderboard name = do +getSampleLeaderboard name = getSampleLeaderboardGeneralized name 1 BySubmitter leaderboardTable + +getSampleAltLeaderboard :: Text -> HandlerFor App (WidgetFor App ()) +getSampleAltLeaderboard name = getSampleLeaderboardGeneralized name 2 ByTag altLeaderboardTable + +getSampleLeaderboardGeneralized name maxPriority method table = do (Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name - (leaderboard, (_, tests)) <- getLeaderboardEntries 1 BySubmitter challengeId + (leaderboard, (_, tests)) <- getLeaderboardEntries maxPriority method challengeId let leaderboardWithRanks = zip [1..] (take 10 leaderboard) app <- getYesod @@ -89,11 +94,13 @@ getSampleLeaderboard name = do challengeRepo <- runDB $ get404 $ challengePublicRepo challenge - return $ Table.buildBootstrap (leaderboardTable Nothing - (challengeName challenge) - scheme challengeRepo tests) + return $ Table.buildBootstrap (table Nothing + (challengeName challenge) + scheme challengeRepo tests) leaderboardWithRanks + + presentationLayout widget = do pc <- widgetToPageContent widget withUrlRenderer $(hamletFile "templates/presentation-layout.hamlet")