From 564f63580eec9d39acfc99b040b0acf394361f1c Mon Sep 17 00:00:00 2001 From: Henri Rabalais Date: Fri, 3 Apr 2026 06:47:50 -0400 Subject: [PATCH 1/3] [DQT] Fix visit list filtering in candidate matching --- modules/dataquery/php/query.class.inc | 6 +----- src/Data/Query/SQLQueryEngine.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/dataquery/php/query.class.inc b/modules/dataquery/php/query.class.inc index ac32b1984c..c4cb2fc82f 100644 --- a/modules/dataquery/php/query.class.inc +++ b/modules/dataquery/php/query.class.inc @@ -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); diff --git a/src/Data/Query/SQLQueryEngine.php b/src/Data/Query/SQLQueryEngine.php index c2c32eb917..f9c91168e5 100644 --- a/src/Data/Query/SQLQueryEngine.php +++ b/src/Data/Query/SQLQueryEngine.php @@ -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'; From 70c197bdc9b5916027c2207e00becbf86ba4294c Mon Sep 17 00:00:00 2001 From: Henri Rabalais Date: Fri, 3 Apr 2026 07:18:24 -0400 Subject: [PATCH 2/3] remove addition of session table to avoid non-unique table name --- src/Data/Query/SQLQueryEngine.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Data/Query/SQLQueryEngine.php b/src/Data/Query/SQLQueryEngine.php index f9c91168e5..e82cfd057b 100644 --- a/src/Data/Query/SQLQueryEngine.php +++ b/src/Data/Query/SQLQueryEngine.php @@ -582,7 +582,6 @@ protected function buildQueryFromCriteria( ); if ($visitlist != null) { - $this->addTable("LEFT JOIN session s ON (s.CandidateID=c.ID AND s.Active='Y')"); $inset = []; $i = count($prepbindings); foreach ($visitlist as $vl) { From 7894ad1cba4aa1552d04e7d970d76463f549b73a Mon Sep 17 00:00:00 2001 From: Henri Rabalais Date: Fri, 3 Apr 2026 07:28:21 -0400 Subject: [PATCH 3/3] passing tests --- src/Data/Query/SQLQueryEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Query/SQLQueryEngine.php b/src/Data/Query/SQLQueryEngine.php index e82cfd057b..2c34c3bbd6 100644 --- a/src/Data/Query/SQLQueryEngine.php +++ b/src/Data/Query/SQLQueryEngine.php @@ -116,7 +116,7 @@ public function getCandidateMatches( $this->addWhereClause("c.Active='Y'"); $prepbindings = []; - $this->buildQueryFromCriteria($term, $prepbindings, $visitList); + $this->buildQueryFromCriteria($term, $prepbindings, $visitlist); $query = 'SELECT DISTINCT c.CandID FROM';