Skip to content

[TTAHUB-5331] Create calculated_category and make services use it#3675

Merged
hardwarehuman merged 3 commits into
mainfrom
ttahub-5331/new_finding_category_handling
Jun 5, 2026
Merged

[TTAHUB-5331] Create calculated_category and make services use it#3675
hardwarehuman merged 3 commits into
mainfrom
ttahub-5331/new_finding_category_handling

Conversation

@hardwarehuman

@hardwarehuman hardwarehuman commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Description of change

We got updated guidance from IT-AMS on where to source the "Category" value for findings. The new guidance is to use MonitoringFindings.source if available, and MonitoringStandards.guidance if not. Instead of having each service figure out what to pull, we add calculated_category to implement the guidance and then all services use that instead.

How to test

The most obvious change is in "Finding category hot spots" where there will be few if any "No finding category assigned" entries. "Health" will go up ~100 or so in total.

Issue(s)

Checklists

Every PR

  • Meets issue criteria
  • JIRA ticket 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

Copilot AI review requested due to automatic review settings June 3, 2026 17:17
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review count: 2 human approvals — thewatermethod, AdamAdHocTeam.

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 centralizes “finding category” selection logic by adding a new Citations.calculated_category field (preferring MonitoringFindings.source when present, otherwise falling back to MonitoringStandards.guidance) and updates monitoring widgets/services to consistently use that derived value.

Changes:

  • Add calculated_category to the Citations fact table population (and to the Citations table/model), including updating FindingCategories to key off calculated_category.
  • Update monitoring widgets/queries and sort logic to use citation.calculated_category instead of citation.guidance_category.
  • Update tests and monitoring fact table documentation to reflect the new canonical category source.

Impact assessment

  • Benefits: Medium — removes duplicated “which field is category?” logic and aligns output with updated IT-AMS guidance.
  • Risks: Medium — touches schema/migration ordering and the monitoring fact-table update pipeline; deployment/migration sequencing should be validated carefully.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/widgets/monitoring/reportCountByFindingCategory.ts Aggregates counts by calculated_category instead of guidance_category.
src/widgets/monitoring/reportCountByFindingCategory.test.js Updates mocks/expectations and test descriptions for calculated_category.
src/widgets/monitoring/monitoringTta.ts Switches category selection + sorting to citation.calculated_category.
src/widgets/monitoring/monitoringTta.test.js Updates fixtures/assertions to use calculated_category.
src/tools/updateMonitoringFactTables.ts Computes/populates calculated_category; updates FindingCategories maintenance and Citations upsert accordingly; includes a defensive column-existence guard.
src/tools/updateMonitoringFactTables.test.js Adds assertions verifying precedence/fallback behavior for calculated_category.
src/models/citation.js Adds Sequelize attribute for calculated_category.
src/migrations/20260602001049-add_calculated_category_to_citations.js Adds the calculated_category column with IF NOT EXISTS guard.
docs/monitoring-fact-tables.md Documents calculated_category and updates FindingCategories description to match.

@thewatermethod

Copy link
Copy Markdown
Collaborator

I'm seeing source_category still in use over calculated_category in src/services/monitoring.ts and src/services/citations.ts is that intended?

@hardwarehuman

Copy link
Copy Markdown
Collaborator Author

I'm seeing source_category still in use over calculated_category in src/services/monitoring.ts and src/services/citations.ts is that intended?

Absolutely not intended

@github-actions github-actions Bot added the review-alerted PR has triggered an overdue review Slack alert label Jun 4, 2026
@hardwarehuman hardwarehuman force-pushed the ttahub-5331/new_finding_category_handling branch from b52c425 to 448e0ef Compare June 4, 2026 19:52
@hardwarehuman

Copy link
Copy Markdown
Collaborator Author

I'm seeing source_category still in use over calculated_category in src/services/monitoring.ts and src/services/citations.ts is that intended?

Fixed the missing files, and found another I hadn't noticed before

thewatermethod
thewatermethod previously approved these changes Jun 4, 2026
@thewatermethod thewatermethod dismissed their stale review June 4, 2026 20:25

Found something that needs a second look in the UI

@thewatermethod thewatermethod left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Dismissed my initial review but then realized I forgot to run the updateMonitoringTables script again post DB reset

@github-actions github-actions Bot removed the review-alerted PR has triggered an overdue review Slack alert label Jun 4, 2026
@hardwarehuman hardwarehuman added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit a840838 Jun 5, 2026
19 checks passed
@hardwarehuman hardwarehuman deleted the ttahub-5331/new_finding_category_handling branch June 5, 2026 18:32
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

📊 Review Metrics

Auto-generated by the PR Review Metrics workflow. Observe-only — no action required.

Metric Value
PR Status ✅ Merged
Reviewer Count 2
Reviewers @thewatermethod, @AdamAdHocTeam
First-Review Turnaround 27.0 hr
Total Review Events 3

Review Timeline

State Reviewer Submitted At
🚫 DISMISSED @thewatermethod 2026-06-04 20:14 UTC
✅ APPROVED @thewatermethod 2026-06-04 20:27 UTC
✅ APPROVED @AdamAdHocTeam 2026-06-05 13:32 UTC

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.

4 participants