[TTAHUB-5378] Fix CLASS same grant matching and align widget/page counts#3706
Conversation
Bumps [fast-xml-builder](https://github.com/NaturalIntelligence/fast-xml-builder) from 1.1.5 to 1.2.0. - [Changelog](https://github.com/NaturalIntelligence/fast-xml-builder/blob/main/CHANGELOG.md) - [Commits](NaturalIntelligence/fast-xml-builder@v1.1.5...v1.2.0) --- updated-dependencies: - dependency-name: fast-xml-builder dependency-version: 1.2.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the QA CLASS dashboard SQL to ensure the widget and details page are driven by the same “qualifying” population: CLASS goals must be linked to an approved activity report, and CLASS scores must be matched on the same grant with a report delivery date on/before the qualifying activity start date.
Changes:
- Refactors
class.sqlto compute qualifying CLASS rows at the grant level (same-grant goal+score matching) and reuse that population for both widget and page datasets. - Adjusts the details-page selection to choose the most recent eligible CLASS score on/before the last approved activity start date.
- Expands backend SQL tests to cover cross-grant mismatches, multi-grant shared reviews, and the “most recent eligible score” selection logic.
Impact assessment:
- Benefits: Medium (fixes correctness and aligns widget/page counts off the same matching rules).
- Risks: Medium (non-trivial SQL refactor affecting dashboard semantics and performance; test cleanup issue noted in comments).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/queries/api/dashboards/qa/class.sql |
Reworks CLASS widget/page dataset logic to match goals and scores on the same grant and select the most recent eligible score relative to approved activity start dates. |
src/queries/api/dashboards/qa/class.test.js |
Updates/extends query tests and adds helpers to create approved activity reports that qualify CLASS goals for matching. |
AdamAdHocTeam
left a comment
There was a problem hiding this comment.
Three things to double check from AI:
- (Medium) New "must have approved AR activity" requirement is a meaningful semantic change
class_goals_with_activity (class.sql:838-862) inner-joins ActivityReportGoals and ActivityReports (LEFT JOIN, but the HAVING MAX(a."startDate") IS NOT NULL makes it effectively required) and filters to calculatedStatus = 'approved'. Goals with no approved AR are now excluded from both the widget numerator and the page list.
Previously the page CTE included rows even when there were no approved ARs (it left-joined and used (ARRAY_AGG(a."startDate" ...))[1] which could be NULL). This means recipients with a CLASS goal and CLASS scores but no approved AR activity yet will drop off the dashboard.
Confirm with the product owner that this is the intended behavior; if so, the JIRA acceptance criteria and any user-facing release notes should say so explicitly.
- (Medium) Reviews delivered after the last approved AR are now ignored
The temporal predicate cgwa."lastARStartDate"::date >= gcr."reportDeliveryDate"::date (class.sql:884) means a CLASS review delivered after all approved AR activity on the goal will not match. The "later review" test case (class.test.js:740 area) exercises this and expects the older review to win.
This is a deliberate change but may surprise users who expect to see the most recent CLASS scores regardless of AR timing. Worth double-checking the requirements; if the intent is "scores known at the time of the most recent TTA work", the rule is correct.
- (Low) vf.name = 'Goals' filter moved from JOIN to FILTER clause
In class_goal_collaborators (class.sql:925-956), the previous query had LEFT JOIN "ValidFor" vf ON ct."validForId" = vf.id AND vf.name = 'Goals', which kept rows for non-Goals collaborator types (with vf.id NULL) but they would still be excluded from the alphabetical-first creator pick because ct.name filters did not exclude them by validFor. The new code requires vf.name = 'Goals' inside each FILTER (...) clause. This is more strictly correct, but is a subtle behavioral tightening worth noting.
|
@AdamAdHocTeam Thanks, I double checked these. |
…-middleware' into kw/ttahub-5378
Description of change
This updates the QA CLASS dashboard backend query so the widget and details dataset use the same grant matching rules.
It requires the CLASS goal and CLASS scores to qualify on the same grant, fixes CLASS summary matching when one review spans multiple grants, and builds the widget counts from the same qualifying grant population used by the details dataset.
This change does not implement the separate timeline based review association rules from TTAHUB-5463.
How to test
Recipients with CLASS scores and goals.Last AR start date.Jira Issue(s)
Checklists
Every PR
Before merge to main
Production Deploy
ready_for_reviewtransition triggers the Slack/Jira automation)elainaparrishis the authorized approver under normal circumstances)After merge/deploy