From d30e61961f763632baa0487a6971bddd2259d0d6 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 29 Sep 2015 14:33:19 +0200 Subject: [PATCH] start evaluation --- Handler/ShowChallenge.hs | 15 +++++++++++++-- config/models | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 9bce406..7b726a5 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -77,8 +77,8 @@ getSubmission repoId commit challengeId description chan = do submissionDescription=description, submissionStamp=time } -getOuts :: Key Submission -> Handler ([Out]) -getOuts submissionId = do +getOuts :: Channel -> Key Submission -> Handler ([Out]) +getOuts chan submissionId = do submission <- runDB $ get404 submissionId let challengeId = submissionChallenge submission let repoDir = getRepoDir $ submissionRepo submission @@ -86,6 +86,7 @@ getOuts submissionId = do testsDone <- filterM (doesOutExist repoDir) activeTests outs <- mapM (outForTest repoDir submissionId) testsDone mapM_ checkOrInsertOut outs + mapM_ (checkOrInsertEvaluation repoDir chan) outs return outs outFileName = "out.tsv" @@ -108,6 +109,16 @@ checkOrInsertOut out = do Just _ -> return () Nothing -> (runDB $ insert out) >> return () +checkOrInsertEvaluation :: FilePath -> Channel -> Out -> Handler () +checkOrInsertEvaluation repoDir chan out = do + test <- runDB $ get404 $ outTest out + maybeEvaluation <- runDB $ getBy $ UniqueEvaluationTestChecksum (outTest out) (outChecksum out) + case maybeEvaluation of + Just (Entity _ evaluation) -> do + msg chan $ concat ["Already evaluated with score ", (T.pack $ fromMaybe "???" $ show <$> evaluationScore evaluation)] + Nothing -> do + msg chan $ "Start evaluation..." + getSubmissionRepo :: Key Challenge -> Text -> Text -> Channel -> Handler (Maybe (Key Repo)) getSubmissionRepo challengeId url branch chan = do maybeRepo <- runDB $ getBy $ UniqueUrlBranch url branch diff --git a/config/models b/config/models index 5ba7611..e9dd15c 100644 --- a/config/models +++ b/config/models @@ -45,7 +45,7 @@ Evaluation score Double Maybe errorMessage Text Maybe stamp UTCTime default=now() - UniqueTestChecksum test checksum + UniqueEvaluationTestChecksum test checksum Out submission SubmissionId test TestId