Skip to content

[dataquery] Fetch accessible instruments in a single query in the dictionary module - #11167

Open
HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:dataquery-dictionary-visit-query-perf
Open

HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:dataquery-dictionary-visit-query-perf

Conversation

@HenriRabalais

@HenriRabalais HenriRabalais commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Description

/dictionary/categories (and /dictionary/module/<name>) scaled linearly with the number of distinct visit labels in the database. getUserModuleCategories() built the set of instruments the user can access by running one Utility::getVisitInstruments() query per visit label, and each of those queries joins session, candidate, flag and test_names.

This replaces the per-visit loop with a single query that fetches the distinct instruments across all of the user's visits.

Changes

  • Replaced the per-visit foreach loop in LORIS\dictionary\Module::getUserModuleCategories() with a single query over all of the user's visits

Testing Instructions

  1. Use a database with a large number of distinct session.Visit_label values.
  2. Log in and open the Data Query Tool, or request GET /dictionary/categories directly.
  3. Confirm the endpoint now returns quickly rather than blocking for tens of seconds.
  4. Confirm the instrument categories shown in the tool are the same as before this change (the response body should be identical).

Related Issues

Closes #11166. The slow loop was introduced in #9903.

@github-actions github-actions Bot added Language: PHP PR or issue that update PHP code Module: dictionary PR or issue related to (new) dictionary module labels Aug 10, 2026
@HenriRabalais
HenriRabalais force-pushed the dataquery-dictionary-visit-query-perf branch from 667b993 to 429e3fc Compare August 10, 2026 23:24
@HenriRabalais HenriRabalais added Module: dataquery PR or issue related to (new) dataquery module and removed Module: dictionary PR or issue related to (new) dictionary module labels Aug 11, 2026
@HenriRabalais
HenriRabalais force-pushed the dataquery-dictionary-visit-query-perf branch from 429e3fc to 32fa8b6 Compare August 11, 2026 10:09
@github-actions github-actions Bot added the Module: dictionary PR or issue related to (new) dictionary module label Aug 11, 2026
@HenriRabalais

Copy link
Copy Markdown
Collaborator Author

@marandmart can you take a look at this when you have the time?

@ridz1208

Copy link
Copy Markdown
Collaborator

@HenriRabalais can you please rebase this to 29.0-release

Move the per-visit instrument lookup out of the dictionary module and into
a batched Utility::getVisitsInstruments() helper that fetches the distinct
instruments for all of the users visits in one query, instead of running
Utility::getVisitInstruments() once per visit label.
@ridz1208 ridz1208 added the State: Needs rebase PR that needs to be rebased to proceed (conflicts, wrong branch...) label Aug 19, 2026
@HenriRabalais
HenriRabalais force-pushed the dataquery-dictionary-visit-query-perf branch from 32fa8b6 to babdda2 Compare August 19, 2026 12:50
@github-actions github-actions Bot added Language: Javascript PR or issue that update Javascript code Module: statistics PR or issue related to statistics module Multilingual Any tasks related to making LORIS multilingual labels Aug 19, 2026
@HenriRabalais
HenriRabalais changed the base branch from main to 29.0-release August 19, 2026 12:50

@marandmart marandmart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HenriRabalais HenriRabalais removed the State: Needs rebase PR that needs to be rebased to proceed (conflicts, wrong branch...) label Aug 31, 2026
@driusan driusan self-assigned this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Module: dataquery PR or issue related to (new) dataquery module Module: dictionary PR or issue related to (new) dictionary module Module: statistics PR or issue related to statistics module Multilingual Any tasks related to making LORIS multilingual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dataquery] /dictionary/categories load time scales with the number of visit labels

4 participants