start working on C3

This commit is contained in:
Filip Gralinski 2018-07-26 22:01:21 +02:00
parent ae75c806c7
commit 276ca4d596
3 changed files with 12 additions and 0 deletions

View File

@ -153,6 +153,8 @@ instance Yesod App where
isAuthorized (ApiTxtScoreR _) _ = return Authorized
isAuthorized (ChallengeParamGraphDataR _ _) _ = return Authorized
-- Default to Authorized for now.
isAuthorized _ _ = isTrustedAuthorized

View File

@ -10,6 +10,15 @@ import Database.Persist.Sql
getChallengeGraphDataR :: Text -> Handler Value
getChallengeGraphDataR challengeName = submissionsToJSON (\_ -> True) challengeName
getChallengeParamGraphDataR :: Text -> Text -> Handler Value
getChallengeParamGraphDataR challengeName paramName = do
return $ object [ "xs" .= object [
"data1" .= ("x1" :: Text),
"data2" .= ("x2" :: Text)],
"columns" .= [
["x1"::Text, "10", "30", "40"],
["x2", "10", "20", "50"] ]]
submissionsToJSON :: ((Entity Submission) -> Bool) -> Text -> Handler Value
submissionsToJSON condition challengeName = do
(Entity challengeId _) <- runDB $ getBy404 $ UniqueName challengeName

View File

@ -20,6 +20,7 @@
/challenge-how-to/#Text ChallengeHowToR GET
/challenge-graph-data/#Text ChallengeGraphDataR GET
/challenge-discussion/#Text ChallengeDiscussionR GET POST
/challenge-param-graph-data/#Text/#Text ChallengeParamGraphDataR GET
/challenge-discussion-rss/#Text ChallengeDiscussionFeedR GET
/trigger-remotely TriggerRemotelyR POST
/trigger-locally TriggerLocallyR POST