[TTAHUB-5399] New overview widget for TR count on TTA History#3690
Draft
AdamAdHocTeam wants to merge 1 commit into
Draft
[TTAHUB-5399] New overview widget for TR count on TTA History#3690AdamAdHocTeam wants to merge 1 commit into
AdamAdHocTeam wants to merge 1 commit into
Conversation
|
✅ Diff size: 362 lines — within the 500-line guideline. |
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a recipient-focused “Training report sessions” metric to the Recipient Record → TTA History overview row by introducing a new backend widget that combines existing Activity Report overview data with a per-recipient Training Report session count, and wiring it into the frontend TTA History page.
Changes:
- Added a new backend widget (
ttaHistoryOverview) that returns AR overview metrics plusnumSessionsfor approved (COMPLETE) TR sessions tied to the recipient’s grants. - Implemented a new backend widget (
trSessionsForRecipient) with accompanying unit tests to compute the per-recipient TR session count. - Updated the frontend DashboardOverview widget definitions and switched the Recipient Record TTA History page/tests to use the new combined widget and field.
Impact assessment: Benefits medium, risks medium (primary risk is potentially expensive TR session counting on large datasets due to application-side filtering).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/widgets/ttaHistoryOverview.ts | New combined backend widget used by the Recipient TTA History tab overview row. |
| src/widgets/trSessionsForRecipient.ts | New backend widget to count COMPLETE TR sessions for a recipient (via recipient grant matching). |
| src/widgets/trSessionsForRecipient.test.ts | Unit tests validating per-recipient TR session counting behavior. |
| src/widgets/index.js | Registers the new widgets in the backend widget registry. |
| frontend/src/widgets/DashboardOverview.js | Adds the new “Training report sessions” field and exports a TTAHistoryOverview widget wrapper. |
| frontend/src/pages/RecipientRecord/pages/TTAHistory.js | Switches TTA History page to use TTAHistoryOverview and includes the new field. |
| frontend/src/pages/RecipientRecord/pages/tests/TTAHistory.js | Updates widget URL expectations and adds coverage for rendering the new field. |
Comment on lines
+61
to
+76
| // Get completed training reports with their complete sessions via shared scope helper | ||
| const reports = (await TrainingReport.findAll({ | ||
| attributes: ['id'], | ||
| ...baseTRScopes(scopes), | ||
| })) as ITrainingReportForSessionCount[]; | ||
|
|
||
| // Count sessions where the recipient has at least one matching grant in data.recipients | ||
| let numSessions = 0; | ||
| reports.forEach((report) => { | ||
| report.sessionReports.forEach((session) => { | ||
| const sessionGrantIds = (session.data.recipients || []).map((r) => r.value); | ||
| if (sessionGrantIds.some((id) => recipientGrantIds.has(id))) { | ||
| numSessions += 1; | ||
| } | ||
| }); | ||
| }); |
Comment on lines
+11
to
+20
| export default async function ttaHistoryOverview( | ||
| scopes: IScopes, | ||
| query: Record<string, unknown> | ||
| ) { | ||
| const [arData, trData] = await Promise.all([ | ||
| overview(scopes), | ||
| trSessionsForRecipient(scopes, query), | ||
| ]); | ||
|
|
||
| return { ...arData, numSessions: trData.numSessions }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
How to test
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