Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions modules/dataquery/php/query.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,7 @@ class Query implements \LORIS\StudyEntities\AccessibleResource,
throw new \Exception("Unhandled operator: " . $crit['op']);
}

// FIXME: Verify visits, test was done with candidate scope data
$visitlist = null;
if (isset($crit['visits'])) {
$visitlist = $crit['visits'];
}
$visitlist = $crit['visits'] ?? null;

\Profiler::checkpoint("Calling engine get matches");
$matches = $engine->getCandidateMatches($term, $visitlist);
Expand Down
15 changes: 12 additions & 3 deletions modules/imaging_browser/php/queryengine.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ class QueryEngine extends \LORIS\Data\Query\SQLQueryEngine
\LORIS\Data\Dictionary\DictionaryItem $item
): string {
if ($item->getName() == 'ScanDone') {
$this->addTable('LEFT JOIN session s ON (s.CandidateID=c.ID)');
$this->addTable(
"LEFT JOIN session s "
. "ON (s.CandidateID=c.ID AND s.Active='Y')"
);
return "CASE WHEN s.Scan_Done='Y' THEN true
WHEN s.Scan_Done='N' THEN false
ELSE NULL END";
Expand All @@ -392,7 +395,10 @@ class QueryEngine extends \LORIS\Data\Query\SQLQueryEngine
// $field = whatever's after the first underscore
$field = substr($item->getName(), strpos($item->getName(), '_') + 1);

$this->addTable('LEFT JOIN session s ON (s.CandidateID=c.ID)');
$this->addTable(
"LEFT JOIN session s "
. "ON (s.CandidateID=c.ID AND s.Active='Y')"
);
$this->addTable("LEFT JOIN files ON (s.ID=files.SessionID)");

if ($item instanceof LocationDictionaryItem) {
Expand Down Expand Up @@ -544,7 +550,10 @@ class QueryEngine extends \LORIS\Data\Query\SQLQueryEngine
|| $item instanceof MRICommentDictionaryItem
|| $item instanceof MRIPredefinedCommentDictionaryItem
) {
$this->addTable('LEFT JOIN session s ON (s.CandidateID=c.ID)');
$this->addTable(
"LEFT JOIN session s "
. "ON (s.CandidateID=c.ID AND s.Active='Y')"
);
$this->addTable("LEFT JOIN files ON (s.ID=files.SessionID)");
return "SUBSTRING_INDEX(files.File, '/', -1)";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Query/SQLQueryEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getCandidateMatches(
$this->addWhereClause("c.Active='Y'");
$prepbindings = [];

$this->buildQueryFromCriteria($term, $prepbindings);
$this->buildQueryFromCriteria($term, $prepbindings, $visitlist);

$query = 'SELECT DISTINCT c.CandID FROM';

Expand Down
Loading