diff --git a/Handler/Query.hs b/Handler/Query.hs index 8dc8e5b..e3a2ff4 100644 --- a/Handler/Query.hs +++ b/Handler/Query.hs @@ -4,6 +4,7 @@ import Import import Handler.SubmissionView import Handler.Shared +import Handler.TagUtils import Database.Persist.Sql @@ -72,6 +73,9 @@ postQueryFormR = do getQueryResultsR :: Text -> Handler Html getQueryResultsR = processQuery +isFullQuery :: Text -> Bool +isFullQuery query = length query == 40 + processQuery :: Text -> Handler Html processQuery query = do submissions <- findSubmissions query diff --git a/Handler/SubmissionView.hs b/Handler/SubmissionView.hs index f352e35..b5f8dce 100644 --- a/Handler/SubmissionView.hs +++ b/Handler/SubmissionView.hs @@ -3,6 +3,7 @@ module Handler.SubmissionView where import Import import Handler.Shared import PersistSHA1 +import Handler.TagUtils import Data.Text as T(pack) @@ -13,7 +14,8 @@ data FullSubmissionInfo = FullSubmissionInfo { fsiRepo :: Repo, fsiChallenge :: Challenge, fsiChallengeRepo :: Repo, - fsiScheme :: RepoScheme} + fsiScheme :: RepoScheme, + fsiTags :: [(Entity Tag, Entity SubmissionTag)] } getFullInfo :: Entity Submission -> Handler FullSubmissionInfo getFullInfo (Entity submissionId submission) = do @@ -22,6 +24,8 @@ getFullInfo (Entity submissionId submission) = do challenge <- runDB $ get404 $ submissionChallenge submission challengeRepo <- runDB $ get404 $ challengePublicRepo challenge + tags <- runDB $ getTags submissionId + app <- getYesod let scheme = appRepoScheme $ appSettings app @@ -32,7 +36,8 @@ getFullInfo (Entity submissionId submission) = do fsiRepo = repo, fsiChallenge = challenge, fsiChallengeRepo = challengeRepo, - fsiScheme = scheme} + fsiScheme = scheme, + fsiTags = tags } queryResult submission = do diff --git a/templates/query-result.hamlet b/templates/query-result.hamlet index a36c2ef..a3de93d 100644 --- a/templates/query-result.hamlet +++ b/templates/query-result.hamlet @@ -1,7 +1,9 @@
#{commitSha1AsText} -
#{submissionDescription $ fsiSubmission submission} +
^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}

 

+
challenge +
#{challengeTitle $ fsiChallenge submission}
submitter
#{submitter}
submitted diff --git a/templates/query-results.hamlet b/templates/query-results.hamlet index 852399a..e3447be 100644 --- a/templates/query-results.hamlet +++ b/templates/query-results.hamlet @@ -1,4 +1,5 @@ -

Query results +$if not (isFullQuery query) || null submissions +

Query results $if null submissions

No results found.