Jump directly to the variant if a query returns just one
This commit is contained in:
parent
1f2a923d9e
commit
601733eba9
@ -275,12 +275,31 @@ getQueryResultsR = processQuery
|
|||||||
isFullQuery :: Text -> Bool
|
isFullQuery :: Text -> Bool
|
||||||
isFullQuery query = length query == 40
|
isFullQuery query = length query == 40
|
||||||
|
|
||||||
|
detectSingleVariantSubmissionQuery :: (PersistQueryRead backend, MonadIO m, BaseBackend backend ~ SqlBackend) => [FullSubmissionInfo] -> ReaderT backend m (Maybe (Key Variant))
|
||||||
|
detectSingleVariantSubmissionQuery [submissionInfo] = do
|
||||||
|
if (null $ fsiSuperSubmissions submissionInfo)
|
||||||
|
then
|
||||||
|
do
|
||||||
|
variants <- selectList [VariantSubmission ==. fsiSubmissionId submissionInfo] []
|
||||||
|
case variants of
|
||||||
|
[Entity variantId _] -> return $ Just variantId
|
||||||
|
_ -> return Nothing
|
||||||
|
else
|
||||||
|
return Nothing
|
||||||
|
detectSingleVariantSubmissionQuery _ = return Nothing
|
||||||
|
|
||||||
processQuery :: Text -> Handler Html
|
processQuery :: Text -> Handler Html
|
||||||
processQuery query = do
|
processQuery query = do
|
||||||
mUserId <- maybeAuthId
|
mUserId <- maybeAuthId
|
||||||
|
|
||||||
submissions' <- findSubmissions query
|
submissions' <- findSubmissions query
|
||||||
let submissions = map fst submissions'
|
let submissions = map fst submissions'
|
||||||
|
|
||||||
|
mSingleVariant <- runDB $ detectSingleVariantSubmissionQuery submissions
|
||||||
|
|
||||||
|
case mSingleVariant of
|
||||||
|
Just singleVariantId -> redirect $ ViewVariantR singleVariantId
|
||||||
|
Nothing -> do
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "query results"
|
setTitle "query results"
|
||||||
$(widgetFile "query-results")
|
$(widgetFile "query-results")
|
||||||
@ -550,6 +569,7 @@ getScoreFromDiff (DiffLineRecord _ _ (TwoThings (_, oldS) (_, newS)) _) = newS -
|
|||||||
data SourceOfExpected = NoExpectedFound | ExpectedFromSubmission | ExpectedFromChallenge
|
data SourceOfExpected = NoExpectedFound | ExpectedFromSubmission | ExpectedFromChallenge
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
checkForExpected :: FilePath -> FilePath -> IO Bool
|
||||||
checkForExpected repoDir testName = do
|
checkForExpected repoDir testName = do
|
||||||
expFile <- lookForCompressedFiles (repoDir </> testName </> "expected.tsv")
|
expFile <- lookForCompressedFiles (repoDir </> testName </> "expected.tsv")
|
||||||
expFileExists <- D.doesFileExist expFile
|
expFileExists <- D.doesFileExist expFile
|
||||||
@ -725,6 +745,7 @@ adjustNumberOfColumnsShown maximumNumberOfColumns tests = adjustNumberOfColumnsS
|
|||||||
minimumNumberOfTests = 2
|
minimumNumberOfTests = 2
|
||||||
|
|
||||||
|
|
||||||
|
canFullInfoBeShown :: (MonadIO m, BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistUniqueRead backend) => Diff (FullSubmissionInfo, b) -> Maybe (Key User) -> ReaderT backend m Bool
|
||||||
canFullInfoBeShown (OneThing (fsi, _)) mUserId = checkWhetherVisible (fsiSubmission fsi) mUserId
|
canFullInfoBeShown (OneThing (fsi, _)) mUserId = checkWhetherVisible (fsiSubmission fsi) mUserId
|
||||||
canFullInfoBeShown (TwoThings (fsiA, _) (fsiB, _)) mUserId = do
|
canFullInfoBeShown (TwoThings (fsiA, _) (fsiB, _)) mUserId = do
|
||||||
checkA <- checkWhetherVisible (fsiSubmission fsiA) mUserId
|
checkA <- checkWhetherVisible (fsiSubmission fsiA) mUserId
|
||||||
|
Loading…
Reference in New Issue
Block a user