Skip to content

[TTAHUB-5399] New overview widget for TR count on TTA History#3690

Draft
AdamAdHocTeam wants to merge 1 commit into
mainfrom
al-ttahub-5399-tr-count-overview-widget
Draft

[TTAHUB-5399] New overview widget for TR count on TTA History#3690
AdamAdHocTeam wants to merge 1 commit into
mainfrom
al-ttahub-5399-tr-count-overview-widget

Conversation

@AdamAdHocTeam

Copy link
Copy Markdown
Collaborator

Description of change

How to test

Jira Issue(s)

Checklists

Every PR

  • Linked Jira issue
  • JIRA issue status updated
  • Code is meaningfully tested
  • Meets accessibility standards (WCAG 2.1 Levels A, AA)
  • API Documentation updated
  • Boundary diagram updated
  • Logical Data Model updated
  • Architectural Decision Records written for major infrastructure decisions
  • UI review complete
  • QA review complete

Before merge to main

  • OHS demo complete
  • Ready to create production PR

Production Deploy

  • PR created as Draft
  • Staging smoke test completed
  • PR transitioned to Open (this ready_for_review transition triggers the Slack/Jira automation)
  • Reviewer added after the PR is Open (elainaparrish is the authorized approver under normal circumstances)
    • Sequence: Draft PR → Smoke test → Open PR (automation runs) → Add reviewer
    • Confirm that the Slack notification was sent after the PR was opened
    • Confirm that linked Jira ticket(s) transitioned as expected; if not, review the GitHub Actions workflow logs

After merge/deploy

  • Update JIRA ticket status

@AdamAdHocTeam AdamAdHocTeam requested a review from Copilot June 10, 2026 21:03
@github-actions

Copy link
Copy Markdown

Diff size: 362 lines — within the 500-line guideline.

@github-actions

Copy link
Copy Markdown

⚠️ Review count advisory: 0 of 2 required human approvals. 2 more needed.

Copilot AI 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.

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 plus numSessions for 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 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants