Show downstream submissions
This commit is contained in:
parent
879eb4e044
commit
ccae7e284f
@ -10,7 +10,6 @@ import PersistSHA1
|
||||
import Handler.Tables
|
||||
|
||||
import qualified Yesod.Table as Table
|
||||
import Yesod.Table (Table)
|
||||
|
||||
import Database.Persist.Sql
|
||||
|
||||
@ -24,7 +23,8 @@ import Data.List (nub)
|
||||
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3)
|
||||
|
||||
rawCommitQuery :: (MonadIO m, RawSql a) => Text -> ReaderT SqlBackend m [a]
|
||||
rawCommitQuery sha1Prefix = rawSql "SELECT ?? FROM submission WHERE is_public AND cast(commit as text) like ?" [PersistText $ "\\\\x" ++ sha1Prefix ++ "%"]
|
||||
rawCommitQuery sha1Prefix =
|
||||
rawSql "SELECT ?? FROM submission WHERE is_public AND cast(commit as text) like ?" [PersistText $ "\\\\x" ++ sha1Prefix ++ "%"]
|
||||
|
||||
findSubmissions :: Text -> Handler [FullSubmissionInfo]
|
||||
findSubmissions sha1Prefix = do
|
||||
@ -111,6 +111,7 @@ resultTable (Entity submissionId submission) = do
|
||||
|
||||
$(widgetFile "result-table")
|
||||
|
||||
queryResult :: FullSubmissionInfo -> WidgetFor App ()
|
||||
queryResult submission = do
|
||||
$(widgetFile "query-result")
|
||||
where commitSha1AsText = fromSHA1ToText $ submissionCommit $ fsiSubmission submission
|
||||
|
@ -1,14 +1,9 @@
|
||||
module Handler.SubmissionView where
|
||||
|
||||
import Import
|
||||
import Handler.Shared
|
||||
import PersistSHA1
|
||||
import Handler.TagUtils
|
||||
|
||||
import Data.Text as T(pack)
|
||||
|
||||
import qualified Yesod.Table as Table
|
||||
import Yesod.Table (Table)
|
||||
import qualified Database.Esqueleto as E
|
||||
import Database.Esqueleto ((^.))
|
||||
|
||||
data FullSubmissionInfo = FullSubmissionInfo {
|
||||
fsiSubmissionId :: SubmissionId,
|
||||
@ -19,7 +14,8 @@ data FullSubmissionInfo = FullSubmissionInfo {
|
||||
fsiChallengeRepo :: Repo,
|
||||
fsiScheme :: RepoScheme,
|
||||
fsiTags :: [(Entity Tag, Entity SubmissionTag)],
|
||||
fsiExternalLinks :: [Entity ExternalLink] }
|
||||
fsiExternalLinks :: [Entity ExternalLink],
|
||||
fsiSuperSubmissions :: [FullSubmissionInfo] }
|
||||
|
||||
getFullInfo :: Entity Submission -> Handler FullSubmissionInfo
|
||||
getFullInfo (Entity submissionId submission) = do
|
||||
@ -35,6 +31,13 @@ getFullInfo (Entity submissionId submission) = do
|
||||
app <- getYesod
|
||||
let scheme = appRepoScheme $ appSettings app
|
||||
|
||||
superSubmissions <- runDB $ E.select $ E.from $ \(submission', dependency) -> do
|
||||
E.where_ (submission' ^. SubmissionCommit E.==. dependency ^. DependencySuperRepoCommit
|
||||
E.&&. dependency ^. DependencySubRepoCommit E.==. (E.val (submissionCommit submission)))
|
||||
return submission'
|
||||
|
||||
superSubmissionFsis <- mapM getFullInfo superSubmissions
|
||||
|
||||
return $ FullSubmissionInfo {
|
||||
fsiSubmissionId = submissionId,
|
||||
fsiSubmission = submission,
|
||||
@ -44,8 +47,10 @@ getFullInfo (Entity submissionId submission) = do
|
||||
fsiChallengeRepo = challengeRepo,
|
||||
fsiScheme = scheme,
|
||||
fsiTags = tags,
|
||||
fsiExternalLinks = links }
|
||||
fsiExternalLinks = links,
|
||||
fsiSuperSubmissions = superSubmissionFsis }
|
||||
|
||||
getTags :: (BaseBackend backend ~ SqlBackend, MonadIO m, PersistQueryRead backend) => Key Submission -> ReaderT backend m [(Entity Tag, Entity SubmissionTag)]
|
||||
getTags submissionId = do
|
||||
sts <- selectList [SubmissionTagSubmission ==. submissionId] []
|
||||
let tagIds = Import.map (submissionTagTag . entityVal) sts
|
||||
|
@ -1,29 +1,39 @@
|
||||
<div .subm-commit>#{commitSha1AsText}
|
||||
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
|
||||
<p> </p>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>challenge
|
||||
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
|
||||
<dt>submitter
|
||||
<dd>#{submitter}
|
||||
<dt>submitted
|
||||
<dd>#{stamp}
|
||||
<dt>original repo
|
||||
<dd><code>#{repoUrl $ fsiRepo submission}</code> / branch <code>#{repoBranch $ fsiRepo submission}</code>
|
||||
$if submissionIsPublic $ fsiSubmission submission
|
||||
<dt>publicly available at
|
||||
<dd><code>#{publicSubmissionRepo}</code> / branch <code>#{publicSubmissionBranch}</code>
|
||||
<dt>browsable at
|
||||
<dd><a href="#{browsableUrl}">#{browsableUrl}</a>
|
||||
<dt>clone by
|
||||
<dd><code>git clone --single-branch #{publicSubmissionRepo} -b #{publicSubmissionBranch}</code>
|
||||
$if not (null (fsiExternalLinks submission))
|
||||
<dt>see also
|
||||
<dd>
|
||||
$forall (Entity _ externalLink) <- fsiExternalLinks submission
|
||||
<a href="#{externalLinkUrl externalLink}">
|
||||
#{fromMaybe (externalLinkUrl externalLink) (externalLinkTitle externalLink)}
|
||||
<br>
|
||||
^{resultTable (Entity (fsiSubmissionId submission) (fsiSubmission submission))}
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<p class="media-object">
|
||||
<span class="glyphicon glyphicon-asterisk" aria-hidden="hidden">
|
||||
<div class="media-body">
|
||||
<div class="media-heading">
|
||||
<div .subm-commit>#{commitSha1AsText}
|
||||
|
||||
<hr>
|
||||
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
|
||||
<p> </p>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>challenge
|
||||
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
|
||||
<dt>submitter
|
||||
<dd>#{submitter}
|
||||
<dt>submitted
|
||||
<dd>#{stamp}
|
||||
<dt>original repo
|
||||
<dd><code>#{repoUrl $ fsiRepo submission}</code> / branch <code>#{repoBranch $ fsiRepo submission}</code>
|
||||
$if submissionIsPublic $ fsiSubmission submission
|
||||
<dt>publicly available at
|
||||
<dd><code>#{publicSubmissionRepo}</code> / branch <code>#{publicSubmissionBranch}</code>
|
||||
<dt>browsable at
|
||||
<dd><a href="#{browsableUrl}">#{browsableUrl}</a>
|
||||
<dt>clone by
|
||||
<dd><code>git clone --single-branch #{publicSubmissionRepo} -b #{publicSubmissionBranch}</code>
|
||||
$if not (null (fsiExternalLinks submission))
|
||||
<dt>see also
|
||||
<dd>
|
||||
$forall (Entity _ externalLink) <- fsiExternalLinks submission
|
||||
<a href="#{externalLinkUrl externalLink}">
|
||||
#{fromMaybe (externalLinkUrl externalLink) (externalLinkTitle externalLink)}
|
||||
<br>
|
||||
^{resultTable (Entity (fsiSubmissionId submission) (fsiSubmission submission))}
|
||||
|
||||
$if not (null (fsiSuperSubmissions submission))
|
||||
<h4>downstream submissions
|
||||
$forall superSubmission <- (fsiSuperSubmissions submission)
|
||||
^{queryResult superSubmission}
|
||||
|
@ -6,3 +6,4 @@ $if null submissions
|
||||
$else
|
||||
$forall submission <- submissions
|
||||
^{queryResult submission}
|
||||
<hr>
|
||||
|
@ -2,6 +2,7 @@
|
||||
$(document).ready(function() {
|
||||
$(#{jsSelector}).DataTable({
|
||||
'pageLength': 50,
|
||||
'lengthChange': false,
|
||||
'order': [[0, 'asc'], [#{delta} + ($.fn.dataTable.getColumnDefs(#{delta}, #{higherTheBetterArray})).length-1, 'desc']],
|
||||
'columnDefs': $.fn.dataTable.getColumnDefs(#{delta}, #{higherTheBetterArray})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user