forked from filipg/gonito
Introduce challenge as competitions
This commit is contained in:
parent
eae31a893d
commit
09aecfb76d
@ -329,7 +329,8 @@ addChallenge name publicRepoId privateRepoId deadline chan = do
|
|||||||
challengeStarred=False,
|
challengeStarred=False,
|
||||||
challengeArchived=Just False,
|
challengeArchived=Just False,
|
||||||
challengeVersion=commit,
|
challengeVersion=commit,
|
||||||
challengeSensitive=Just False }
|
challengeSensitive=Just False,
|
||||||
|
challengeIsCompetition=Just False}
|
||||||
|
|
||||||
_ <- runDB $ insert $ Version {
|
_ <- runDB $ insert $ Version {
|
||||||
versionChallenge=Just challengeId,
|
versionChallenge=Just challengeId,
|
||||||
|
@ -139,10 +139,8 @@ instance ToSchema LeaderboardView where
|
|||||||
|
|
||||||
getLeaderboardJsonR :: Text -> Handler Value
|
getLeaderboardJsonR :: Text -> Handler Value
|
||||||
getLeaderboardJsonR challengeName = do
|
getLeaderboardJsonR challengeName = do
|
||||||
app <- getYesod
|
Entity challengeId challenge <- runDB $ getBy404 $ UniqueName challengeName
|
||||||
let leaderboardStyle = appLeaderboardStyle $ appSettings app
|
leaderboardStyle <- determineLeaderboardStyle challenge
|
||||||
|
|
||||||
Entity challengeId _ <- runDB $ getBy404 $ UniqueName challengeName
|
|
||||||
(leaderboard, (_, tests)) <- getLeaderboardEntries 1 leaderboardStyle challengeId
|
(leaderboard, (_, tests)) <- getLeaderboardEntries 1 leaderboardStyle challengeId
|
||||||
return $ toJSON $ LeaderboardView {
|
return $ toJSON $ LeaderboardView {
|
||||||
leaderboardViewTests = tests,
|
leaderboardViewTests = tests,
|
||||||
@ -192,12 +190,19 @@ toLeaderboardEntryView tests entry = LeaderboardEntryView {
|
|||||||
map (convertEvaluationToView (leaderboardEvaluationMap entry)) tests
|
map (convertEvaluationToView (leaderboardEvaluationMap entry)) tests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
determineLeaderboardStyle :: Challenge -> Handler LeaderboardStyle
|
||||||
|
determineLeaderboardStyle challenge = do
|
||||||
|
app <- getYesod
|
||||||
|
let leaderboardStyle = appLeaderboardStyle $ appSettings app
|
||||||
|
return $ case challengeIsCompetition challenge of
|
||||||
|
Just True -> BySubmitter
|
||||||
|
_ -> leaderboardStyle
|
||||||
|
|
||||||
getShowChallengeR :: Text -> Handler Html
|
getShowChallengeR :: Text -> Handler Html
|
||||||
getShowChallengeR challengeName = do
|
getShowChallengeR challengeName = do
|
||||||
app <- getYesod
|
app <- getYesod
|
||||||
let leaderboardStyle = appLeaderboardStyle $ appSettings app
|
|
||||||
|
|
||||||
challengeEnt@(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName challengeName
|
challengeEnt@(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName challengeName
|
||||||
|
leaderboardStyle <- determineLeaderboardStyle challenge
|
||||||
|
|
||||||
isHealthy <- isChallengeHealthy challenge
|
isHealthy <- isChallengeHealthy challenge
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ Challenge
|
|||||||
archived Bool Maybe
|
archived Bool Maybe
|
||||||
version SHA1
|
version SHA1
|
||||||
sensitive Bool Maybe
|
sensitive Bool Maybe
|
||||||
|
-- forces BySubmitter leaderboard style
|
||||||
|
isCompetition Bool Maybe
|
||||||
-- challenge version
|
-- challenge version
|
||||||
Version
|
Version
|
||||||
-- introduced later, hence Maybe
|
-- introduced later, hence Maybe
|
||||||
|
Loading…
Reference in New Issue
Block a user