Skip to content

Phase B.3.1: Operational decision dashboard core - #60

Merged
henter36 merged 8 commits into
mainfrom
phase-b31-operational-decision-dashboard
Jul 21, 2026
Merged

Phase B.3.1: Operational decision dashboard core#60
henter36 merged 8 commits into
mainfrom
phase-b31-operational-decision-dashboard

Conversation

@henter36

@henter36 henter36 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add operational dashboard query service with scope, note-type, and sensitive-note exclusion before SQL aggregation
  • Expose four scoped API endpoints (summary, trends, breakdowns, priority-queues) and RTL /dashboard UI with drill-down links
  • Seed Dashboard.* permissions, extend notes/CA list URL filters for parity, and add unit/integration/frontend test coverage plus phase docs

Test plan

  • dotnet build src/backend/Baseera.slnx -c Release
  • Unit tests: 337 passed, 0 skipped
  • Integration tests: 87 passed, 0 skipped (BASEERA_TEST_CONNECTION)
  • Frontend: typecheck, lint, 112 tests, build, audit (0 high/critical)
  • CI green on PR

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Added the Operational Decision Dashboard at /dashboard (summary, trends, breakdowns, and priority queues) with drill-down links and permission-based section visibility.
    • Added new dashboard API contract and baseline/security/testing documentation for Phase B.3.1.
    • Extended note lists with due-soon and unassigned filtering, synced to URL state.
  • Bug Fixes
    • Improved API input handling by returning a clear HTTP 400 for invalid arguments.
  • Documentation
    • Updated implementation/phase notes and added/expanded dashboard scope, permissions matrix, completion, and security guides.

henter36 and others added 2 commits July 21, 2026 08:41
Add scoped dashboard query service, four API endpoints, permissions, RTL /dashboard UI, drill-down list parity, tests, and phase documentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @henter36, your pull request is larger than the review limit of 150000 diff characters

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e53dc504-333b-4a12-bc93-5144260159c5

📥 Commits

Reviewing files that changed from the base of the PR and between f68b5e8 and f4a5ff0.

📒 Files selected for processing (3)
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardAggregationHelpers.cs
  • src/backend/tests/Baseera.IntegrationTests/OperationalDashboardQueryCountIntegrationTests.cs
  • src/frontend/src/pages/notes/notesListSearchParams.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/frontend/src/pages/notes/notesListSearchParams.ts
  • src/backend/tests/Baseera.IntegrationTests/OperationalDashboardQueryCountIntegrationTests.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardAggregationHelpers.cs

📝 Walkthrough

Walkthrough

Adds the Phase B.3.1 operational dashboard with scoped backend aggregation, permissions, API endpoints, an RTL frontend page, drill-down filters, URL-synchronized list state, documentation, and automated tests.

Changes

Operational dashboard

Layer / File(s) Summary
Phase documentation and contracts
README.md, docs/...
Updates phase status and documents dashboard scope, API contracts, security rules, baseline, completion status, and test coverage.
Backend contracts and aggregation
src/backend/Baseera.Application/Dashboard/*, src/backend/Baseera.Api/*, src/backend/Baseera.Infrastructure/*
Adds dashboard DTOs, scoped KPI aggregation, trends, breakdowns, priority queues, permissions, endpoints, DI registration, role grants, and validation handling.
Frontend dashboard and drill-downs
src/frontend/src/App.tsx, src/frontend/src/api/*, src/frontend/src/pages/dashboard/*, src/frontend/src/index.css
Adds the protected dashboard route, API client methods, RTL metrics and trend rendering, permission gates, loading/error states, styling, and drill-down links.
URL-synchronized list filters
src/frontend/src/pages/notes/*, src/frontend/src/pages/corrective-actions/*
Initializes list state from URL parameters and synchronizes filters, pagination, and sorting back to the URL.
Automated validation
src/backend/tests/*, src/frontend/src/pages/dashboard/*.test.*, src/frontend/src/pages/notes/*SearchParams.test.ts
Tests authorization, scoping, KPI semantics, time boundaries, query counts, queue limits, API responses, rendering, errors, and drill-down URLs.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DashboardPage
  participant DashboardApi
  participant DashboardEndpoints
  participant DashboardQueryService
  participant Database
  DashboardPage->>DashboardApi: request dashboard data
  DashboardApi->>DashboardEndpoints: GET dashboard operation endpoint
  DashboardEndpoints->>DashboardQueryService: execute filtered query
  DashboardQueryService->>Database: aggregate scoped notes and corrective actions
  Database-->>DashboardQueryService: return aggregates
  DashboardQueryService-->>DashboardEndpoints: return dashboard DTO
  DashboardEndpoints-->>DashboardApi: return HTTP response
  DashboardApi-->>DashboardPage: render dashboard
Loading

Possibly related PRs

  • henter36/Baseera#1 — Provides the authorization policy infrastructure extended with dashboard permissions.
  • henter36/Baseera#7 — Introduced note-type access and deny-override rules used by dashboard filtering.
  • henter36/Baseera#8 — Introduced routing decision behavior consumed by dashboard KPIs and queues.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: Phase B.3.1 adds the operational decision dashboard core.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase-b31-operational-decision-dashboard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements Phase B.3.1, introducing the Operational Decision Dashboard Core. It adds backend services, API endpoints, permissions, and a React-based RTL frontend page at /dashboard with KPI summaries, trends, breakdowns, and priority queues, as well as drill-down parity filters on the notes list. The reviewer feedback highlights critical performance improvements, specifically addressing an N+1 query bottleneck in the trends calculation, recommending the consolidation of multiple database count queries in the summary endpoint into a single projection, and suggesting centralized exception handling to eliminate duplicated try-catch blocks across the new endpoints.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/backend/Baseera.Api/Endpoints/ApiEndpoints.cs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs (1)

147-206: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Trend aggregation issues 6 DB round trips per bucket.

The per-bucket loop runs notesCreated, notesCompleted, notesBecameOverdue, caCompleted, routingSuccess, and routingFailure as separate CountAsync calls. For daily granularity (up to ~59 buckets) this is ~350+ sequential queries per trends request, plus the summary path repeatedly re-materializes scoped note IDs. Consider a single grouped/bucketed aggregation per metric (e.g., GroupBy on a computed bucket key) to collapse this into a handful of queries.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs`
around lines 147 - 206, Refactor the trend aggregation around the per-bucket
loop so the six sequential CountAsync calls are replaced by grouped, bucketed
queries that aggregate each metric across all buckets in a handful of database
round trips. Reuse the scoped note and corrective-action queryables, materialize
each grouped result once, and populate points from lookup results while
preserving the existing bucket boundaries, filters, and zero values for missing
buckets.
src/frontend/src/pages/notes/NotesListPage.tsx (1)

97-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce cognitive complexity of the URL-sync effect (SonarCloud gate).

SonarCloud reports this effect at cognitive complexity 17 (limit 15), which is failing the check. Extract the param-building into a small pure helper (e.g. buildNotesSearchParams(state)) and call setSearchParams with its result to bring it under the threshold without behavior change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/frontend/src/pages/notes/NotesListPage.tsx` around lines 97 - 117, The
URL synchronization effect in NotesListPage currently builds parameters with
excessive branching. Extract that logic into a pure helper such as
buildNotesSearchParams, passing the relevant filter, pagination, and sorting
state, then have the effect call setSearchParams with the helper’s result while
preserving all existing parameter inclusion and replacement behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/phase-b31-dashboard-baseline.md`:
- Around line 4-10: Reconcile the unit-test count in the pre-B.3.1 baseline for
base SHA afb796b2bd85a1ae26b91b8f6e67b7646d024f06 with the 287-test B.2.3.2
completion report. Update the baseline to the matching count, or document the
differing test commands or scope that account for 298 versus 287, keeping the
phase comparison auditable.

In
`@src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs`:
- Around line 775-792: Update the facility name resolution in the
OperationalDashboardOverdueLocationQueueItemDto projection to use
facilities.TryGetValue instead of the direct facilities indexer, returning a
safe null or established fallback when the facility is absent while preserving
the existing region resolution and queue item mapping.
- Around line 594-641: The severity and status breakdown builders return a
hardcoded corrective-action overdue value of zero despite receiving actions. In
BuildSeverityBreakdownAsync and the sibling builder at
src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs
lines 643-690, join or otherwise aggregate the matching actions to populate
caOverdue consistently with the region, facility, and note-type breakdowns; if
corrective-action reporting is intentionally excluded, remove the unused actions
parameter and ensure both sites reflect that decision.

In `@src/frontend/src/index.css`:
- Line 327: Update the metric card border declaration using the visible border
property to reference the defined --line CSS variable instead of --border,
preserving the existing 1px solid styling.

In `@src/frontend/src/pages/dashboard/dashboardDrillDown.ts`:
- Line 23: Update the sortDesc serialization near the dashboard drill-down
parameter construction to set the URL parameter whenever filters.sortDesc is
defined, emitting its boolean value as a string so false is preserved. Keep
omission only for an unset value, allowing NotesListPage to distinguish explicit
ascending order from the default descending order.

---

Nitpick comments:
In
`@src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs`:
- Around line 147-206: Refactor the trend aggregation around the per-bucket loop
so the six sequential CountAsync calls are replaced by grouped, bucketed queries
that aggregate each metric across all buckets in a handful of database round
trips. Reuse the scoped note and corrective-action queryables, materialize each
grouped result once, and populate points from lookup results while preserving
the existing bucket boundaries, filters, and zero values for missing buckets.

In `@src/frontend/src/pages/notes/NotesListPage.tsx`:
- Around line 97-117: The URL synchronization effect in NotesListPage currently
builds parameters with excessive branching. Extract that logic into a pure
helper such as buildNotesSearchParams, passing the relevant filter, pagination,
and sorting state, then have the effect call setSearchParams with the helper’s
result while preserving all existing parameter inclusion and replacement
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 20343b57-ef69-4b15-9128-63ec13437fbb

📥 Commits

Reviewing files that changed from the base of the PR and between afb796b and 0c964e0.

📒 Files selected for processing (36)
  • README.md
  • docs/implementation-plan.md
  • docs/permissions-matrix.md
  • docs/phase-b232-note-routing-completion-report.md
  • docs/phase-b31-dashboard-api-contract.md
  • docs/phase-b31-dashboard-baseline.md
  • docs/phase-b31-dashboard-completion-report.md
  • docs/phase-b31-dashboard-scope.md
  • docs/phase-b31-dashboard-security.md
  • docs/phase-b31-dashboard-test-matrix.md
  • src/backend/Baseera.Api/Authorization/AuthorizationExtensions.cs
  • src/backend/Baseera.Api/Endpoints/ApiEndpoints.cs
  • src/backend/Baseera.Api/Endpoints/NoteListQueryParams.cs
  • src/backend/Baseera.Api/Endpoints/OperationalDashboardQueryParams.cs
  • src/backend/Baseera.Application/Dashboard/IOperationalDashboardQueryService.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardDtos.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardFilterBuilder.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardKpiDefinitions.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs
  • src/backend/Baseera.Application/DependencyInjection/ApplicationServiceCollectionExtensions.cs
  • src/backend/Baseera.Application/Notes/NoteDtos.cs
  • src/backend/Baseera.Application/Notes/NoteQueryService.cs
  • src/backend/Baseera.Domain/Identity/IdentityEntities.cs
  • src/backend/Baseera.Infrastructure/Persistence/DatabaseInitializer.cs
  • src/backend/tests/Baseera.IntegrationTests/OperationalDashboardIntegrationTests.cs
  • src/backend/tests/Baseera.UnitTests/Dashboard/OperationalDashboardQueryServiceTests.cs
  • src/frontend/src/App.tsx
  • src/frontend/src/api/client.ts
  • src/frontend/src/index.css
  • src/frontend/src/pages/corrective-actions/CorrectiveActionsListPage.tsx
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.permission.test.tsx
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.test.tsx
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.tsx
  • src/frontend/src/pages/dashboard/dashboardDrillDown.test.ts
  • src/frontend/src/pages/dashboard/dashboardDrillDown.ts
  • src/frontend/src/pages/notes/NotesListPage.tsx

Comment thread docs/phase-b31-dashboard-baseline.md
Comment thread src/frontend/src/index.css Outdated
Comment thread src/frontend/src/pages/dashboard/dashboardDrillDown.ts Outdated
henter36 and others added 4 commits July 21, 2026 09:08
Consolidate summary KPIs into SQL-side aggregates, replace trends per-bucket queries with fixed daily routing queries merged in memory, deduplicate breakdown builders, and fix severity/status corrective-action overdue counts with query-count tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/frontend/src/pages/notes/notesListSearchParams.ts (1)

3-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce cognitive complexity to clear the SonarCloud gate. The linear if-chain reports cognitive complexity 19 (limit 15) and is failing the SonarCloud check. Extracting the simple string-field assignments into a small table keeps the special cases (page > 1, sortBy !== 'createdAtUtc', sortDesc === false) explicit while dropping the count below threshold.

♻️ Example table-driven approach
export function buildNotesListSearchParams(filters: NoteListFilters): URLSearchParams {
  const params = new URLSearchParams()

  const stringFields: [keyof NoteListFilters, string][] = [
    ['search', 'search'],
    ['noteTypeId', 'noteTypeId'],
    ['regionId', 'regionId'],
    ['facilityId', 'facilityId'],
    ['facilityUnitId', 'facilityUnitId'],
    ['ownerDepartmentId', 'ownerDepartmentId'],
  ]
  for (const [key, param] of stringFields) {
    const value = filters[key]
    if (value) params.set(param, String(value))
  }

  const numericFields: [keyof NoteListFilters, string][] = [
    ['status', 'status'],
    ['severity', 'severity'],
    ['classification', 'classification'],
    ['dueSoonDays', 'dueSoonDays'],
  ]
  for (const [key, param] of numericFields) {
    const value = filters[key]
    if (value != null) params.set(param, String(value))
  }

  const boolFlags: [keyof NoteListFilters, string][] = [
    ['overdueOnly', 'overdueOnly'],
    ['unassignedOnly', 'unassignedOnly'],
    ['requiresMyAction', 'requiresMyAction'],
    ['requiresRouting', 'requiresRouting'],
  ]
  for (const [key, param] of boolFlags) {
    if (filters[key]) params.set(param, 'true')
  }

  if (filters.page != null && filters.page > 1) params.set('page', String(filters.page))
  if (filters.sortBy && filters.sortBy !== 'createdAtUtc') params.set('sortBy', filters.sortBy)
  if (filters.sortDesc === false) params.set('sortDesc', 'false')
  return params
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/frontend/src/pages/notes/notesListSearchParams.ts` around lines 3 - 23,
Reduce cognitive complexity in buildNotesListSearchParams by grouping the
straightforward string, nullable numeric, and boolean fields into table-driven
loops that set their corresponding parameters. Keep the special-case handling
for page > 1, non-default sortBy, and sortDesc === false explicit and preserve
all existing truthiness and null checks.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/frontend/src/pages/notes/notesListSearchParams.ts`:
- Around line 3-23: Reduce cognitive complexity in buildNotesListSearchParams by
grouping the straightforward string, nullable numeric, and boolean fields into
table-driven loops that set their corresponding parameters. Keep the
special-case handling for page > 1, non-default sortBy, and sortDesc === false
explicit and preserve all existing truthiness and null checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 19a6ff19-81cd-43e2-a3c8-b5bd0844dab0

📥 Commits

Reviewing files that changed from the base of the PR and between e73d7c0 and f68b5e8.

📒 Files selected for processing (11)
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardAggregationHelpers.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardFilterBuilder.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardKpiDefinitions.cs
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardQueryService.cs
  • src/backend/tests/Baseera.IntegrationTests/OperationalDashboardQueryCountIntegrationTests.cs
  • src/backend/tests/Baseera.UnitTests/Dashboard/OperationalDashboardQueryServiceTests.cs
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.test.tsx
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.tsx
  • src/frontend/src/pages/notes/NotesListPage.tsx
  • src/frontend/src/pages/notes/notesListSearchParams.test.ts
  • src/frontend/src/pages/notes/notesListSearchParams.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.test.tsx
  • src/frontend/src/pages/notes/NotesListPage.tsx
  • src/backend/Baseera.Application/Dashboard/OperationalDashboardFilterBuilder.cs
  • src/frontend/src/pages/dashboard/OperationalDashboardPage.tsx

@sonarqubecloud

Copy link
Copy Markdown

@henter36
henter36 merged commit 66f35f3 into main Jul 21, 2026
7 checks passed
@henter36
henter36 deleted the phase-b31-operational-decision-dashboard branch July 21, 2026 11:09
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.

1 participant