forked from filipg/gonito
clean up code a little bit
This commit is contained in:
parent
0a51543957
commit
5105652838
@ -110,10 +110,17 @@ getChallengeHowToR name = do
|
|||||||
Nothing -> False
|
Nothing -> False
|
||||||
isSSHUploaded <- case maybeUser of
|
isSSHUploaded <- case maybeUser of
|
||||||
Just (Entity userId _) -> do
|
Just (Entity userId _) -> do
|
||||||
keys <- runDB $ selectList [PublicKeyUser ==. userId] []
|
ukeys <- runDB $ selectList [PublicKeyUser ==. userId] []
|
||||||
return $ not (null keys)
|
return $ not (null ukeys)
|
||||||
Nothing -> return False
|
Nothing -> return False
|
||||||
challengeLayout False challenge (challengeHowTo challenge settings repo (idToBeShown challenge maybeUser) isIDSet isSSHUploaded mToken)
|
challengeLayout False challenge (challengeHowTo
|
||||||
|
challenge
|
||||||
|
settings
|
||||||
|
repo
|
||||||
|
(idToBeShown challenge maybeUser)
|
||||||
|
isIDSet
|
||||||
|
isSSHUploaded
|
||||||
|
mToken)
|
||||||
|
|
||||||
idToBeShown :: p -> Maybe (Entity User) -> Text
|
idToBeShown :: p -> Maybe (Entity User) -> Text
|
||||||
idToBeShown _ maybeUser =
|
idToBeShown _ maybeUser =
|
||||||
@ -257,13 +264,14 @@ findTagsLine = tagsLine <|> (anyLine >> findTagsLine)
|
|||||||
|
|
||||||
tagsLine :: Data.Attoparsec.Text.Parser Text
|
tagsLine :: Data.Attoparsec.Text.Parser Text
|
||||||
tagsLine = do
|
tagsLine = do
|
||||||
(string "tags" <|> string "labels" <|> string "Tags" <|> string "Labels")
|
_ <- (string "tags" <|> string "labels" <|> string "Tags" <|> string "Labels")
|
||||||
char ':'
|
_ <- char ':'
|
||||||
skipMany space
|
skipMany space
|
||||||
s <- many notEndOfLine
|
s <- many notEndOfLine
|
||||||
endOfLine
|
endOfLine
|
||||||
return $ Data.Text.pack s
|
return $ Data.Text.pack s
|
||||||
|
|
||||||
|
commaSep :: Data.Attoparsec.Text.Parser a -> Data.Attoparsec.Text.Parser [a]
|
||||||
commaSep p = p `sepBy` (skipMany space *> char ',' *> skipMany space)
|
commaSep p = p `sepBy` (skipMany space *> char ',' *> skipMany space)
|
||||||
|
|
||||||
nonEmptyLine :: Data.Attoparsec.Text.Parser Text
|
nonEmptyLine :: Data.Attoparsec.Text.Parser Text
|
||||||
@ -285,9 +293,9 @@ notSpace = satisfy (\c -> c /= '\r' && c /= '\n' && c /= ' ' && c /= '\t')
|
|||||||
notEndOfLine :: Data.Attoparsec.Text.Parser Char
|
notEndOfLine :: Data.Attoparsec.Text.Parser Char
|
||||||
notEndOfLine = satisfy (\c -> c /= '\r' && c /= '\n')
|
notEndOfLine = satisfy (\c -> c /= '\r' && c /= '\n')
|
||||||
|
|
||||||
|
emptyLine :: Data.Attoparsec.Text.Parser ()
|
||||||
emptyLine = do
|
emptyLine = do
|
||||||
many space
|
many space *> endOfLine
|
||||||
endOfLine
|
|
||||||
|
|
||||||
getOuts :: Channel -> Key Submission -> Handler ([Out])
|
getOuts :: Channel -> Key Submission -> Handler ([Out])
|
||||||
getOuts chan submissionId = do
|
getOuts chan submissionId = do
|
||||||
@ -502,15 +510,31 @@ getChallengeSubmissions condition name = do
|
|||||||
$ concat
|
$ concat
|
||||||
$ map (\entry -> map (parameterName . entityVal) (tableEntryParams entry)) evaluationMaps
|
$ map (\entry -> map (parameterName . entityVal) (tableEntryParams entry)) evaluationMaps
|
||||||
|
|
||||||
challengeLayout True challenge (challengeAllSubmissionsWidget muserId challenge scheme challengeRepo evaluationMaps tests params)
|
challengeLayout True challenge (challengeAllSubmissionsWidget muserId
|
||||||
|
challenge
|
||||||
|
scheme
|
||||||
|
challengeRepo
|
||||||
|
evaluationMaps
|
||||||
|
tests
|
||||||
|
params)
|
||||||
|
|
||||||
challengeAllSubmissionsWidget :: Maybe UserId -> Challenge -> RepoScheme -> Repo -> [TableEntry] -> [Entity Test] -> [Text] -> WidgetFor App ()
|
challengeAllSubmissionsWidget :: Maybe UserId
|
||||||
|
-> Challenge
|
||||||
|
-> RepoScheme
|
||||||
|
-> Repo
|
||||||
|
-> [TableEntry]
|
||||||
|
-> [Entity Test]
|
||||||
|
-> [Text]
|
||||||
|
-> WidgetFor App ()
|
||||||
challengeAllSubmissionsWidget muserId challenge scheme challengeRepo submissions tests params =
|
challengeAllSubmissionsWidget muserId challenge scheme challengeRepo submissions tests params =
|
||||||
$(widgetFile "challenge-all-submissions")
|
$(widgetFile "challenge-all-submissions")
|
||||||
where chartJSs = mconcat $ map (getChartJs challenge mainTest) params
|
where chartJSs = mconcat $ map (getChartJs challenge mainTest) params
|
||||||
mainTest = entityVal $ getMainTest tests
|
mainTest = entityVal $ getMainTest tests
|
||||||
|
|
||||||
getChartJs :: Challenge -> Test -> Text -> JavascriptUrl (Route App)
|
getChartJs :: Challenge
|
||||||
|
-> Test
|
||||||
|
-> Text
|
||||||
|
-> JavascriptUrl (Route App)
|
||||||
getChartJs challenge test param = [julius|
|
getChartJs challenge test param = [julius|
|
||||||
$.getJSON("@{ChallengeParamGraphDataR (challengeName challenge) param}", function(data) {
|
$.getJSON("@{ChallengeParamGraphDataR (challengeName challenge) param}", function(data) {
|
||||||
c3.generate({
|
c3.generate({
|
||||||
|
Loading…
Reference in New Issue
Block a user