fixing analytics dashboard #2323
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2323
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2323/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #1774
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1774
Original created: 2025-10-15T15:17:19Z
Original updated: 2025-10-15T16:11:17Z
Original head: carverauto/serviceradar:1766-bugui-analytics-dashboard-slow-load
Original base: main
Original merged: 2025-10-15T16:08:16Z by @mfreeman451
PR Type
Enhancement, Bug fix
Description
Migrated analytics dashboard from REST API to SRQL queries for improved performance
Refactored service statistics computation from client-side to server-side aggregation
Consolidated sysmon and rperf data fetching to use SRQL-based services
Added
rperf_metricsentity mapping to SRQL engineDiagram Walkthrough
File Walkthrough
11 files
Moved service statistics computation to server-sideRefactored to compute service stats server-side with SRQLMigrated from REST API to SRQL queriesReplaced REST endpoints with SRQL-based data aggregationAdded `rperf_metrics` entity mapping to SRQLSimplified dashboard to use pre-computed service countsUpdated to consume sysmon summary data structureRefactored to use sysmon context with SRQL dataMigrated to sysmon service with SRQL-based summariesUpdated interface to include pre-computed service statisticsChanged data type to use `SysmonAgentSummary`1 files
Added tests for sysmon stats and rperf metricsImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1774#issuecomment-3406980488
Original created: 2025-10-15T15:18:05Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 #1766
REST endpoints after SRQL switch.
pollers/agents.
(failures, latency).
in DevTools.
multiple pollers/agents.
Codebase context is not defined
Follow the guide to enable codebase context checks.
No custom compliance provided
Follow the guide to enable custom compliance check.
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1774#issuecomment-3406988586
Original created: 2025-10-15T15:19:43Z
PR Code Suggestions ✨
Latest suggestions up to
0982dd8Guard state updates after unmount
Add a cancellation flag to the
useEffecthook to prevent state updates on thecomponent after it has unmounted, avoiding potential React warnings and memory
leaks.
web/src/contexts/AnalyticsContext.tsx [40-79]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a potential race condition that could lead to state updates on an unmounted component, which is a valid concern in React. The proposed fix using a cancellation flag is a standard and effective pattern to prevent this issue.
Prevent undefined disks crash
To prevent potential runtime errors, add a nullish coalescing operator to
default
summary.disksto an empty array before iterating over it.web/src/components/Analytics/HighUtilizationWidget.tsx [180-217]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a potential runtime error if
summary.disksisundefined, and the proposed nullish coalescing operator (?? []) is an effective safeguard, improving code robustness.Default device counts safely
Add fallback values for
totalDevicesandofflineDevicesto prevent renderingundefinedin case of partial data from the backend.web/src/components/Analytics/Dashboard.tsx [92-106]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: This is a good defensive coding practice that ensures
totalDevicesandofflineDeviceshave a default value of0, preventing potentialundefinedvalues and improving the component's resilience to partial API responses.Previous suggestions
Suggestions up to commit
2e378c5Consolidate data fetching into single service
Consolidate the newly introduced
analyticsService,sysmonService, andrperfServiceinto a single data service. This change would centralize sharedlogic for caching, error handling, and SRQL queries, reducing code duplication.
Examples:
web/src/services/sysmonService.ts [89-124]
web/src/services/rperfService.ts [67-110]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 8
__
Why: This is a significant architectural suggestion that correctly identifies substantial code duplication for caching, subscriptions, and SRQL execution logic across the new
analyticsService,rperfService, andsysmonService.Use helper for consistent data extraction
Refactor
totalDevicesandofflineDevicesextraction to use thethis.extractTotalhelper method for consistency and robustness.
web/src/services/analyticsService.ts [219-264]
Suggestion importance[1-10]: 5
__
Why: The suggestion correctly points out an inconsistency and improves code maintainability by refactoring to use the existing
this.extractTotalhelper method.Remove redundant client-side sorting
Remove the redundant client-side sorting of
rperfmetrics, as the data isalready sorted by the initial database query.
web/src/services/rperfService.ts [112-148]
Suggestion importance[1-10]: 4
__
Why: The suggestion correctly identifies a redundant client-side sort and proposes its removal, which is a valid optimization, although with minor performance impact.