feat: abbreviate large numbers on analytics stats cards #2998
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!2998
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2998/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: #2960
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2960
Original created: 2026-03-01T03:49:00Z
Original updated: 2026-03-01T03:54:04Z
Original head: carverauto/serviceradar:2371-abbreviate-analytics-numbers
Original base: staging
Original merged: 2026-03-01T03:54:02Z by @mfreeman451
User description
Summary
50,000) to compact abbreviations (50k,1.5M,2.3B)format_compact_number/1helper instead offormat_number/1format_number/1andadd_commas/1functionsCloses #2371
Test plan
50kinstead of50,000)🤖 Generated with Claude Code
PR Type
Enhancement
Description
Replace comma-formatted numbers with compact abbreviations (50k, 1.5M, 2.3B)
Apply formatting to stat cards, device availability counts, and log severity table
Remove unused
format_number/1andadd_commas/1helper functionsDiagram Walkthrough
File Walkthrough
index.ex
Switch to compact number formatting throughout analyticselixir/web-ng/lib/serviceradar_web_ng_web/live/analytics_live/index.ex
format_number/1calls withformat_compact_number/1in statcard display
format_number/1calls withformat_compact_number/1in deviceavailability widget (online/offline counts)
format_number/1calls withformat_compact_number/1in logseverity table row component
format_number/1function (4 clauses handling integers,floats, and fallback)
add_commas/1helper function that formatted numbers withcomma separators
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2960#issuecomment-3979009221
Original created: 2026-03-01T03:49:23Z
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.🎫 #2371
50k devicesinsteadof
50,000 devices).Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status: Passed
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Missing fallback clause:
format_compact_number/1only matches integers/floats and may raise aFunctionClauseErrorif any of the new call sites pass
nilor a non-number.Referred Code
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/2960#issuecomment-3979010523
Original created: 2026-03-01T03:50:04Z
CI Feedback 🧐
A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
Action: build
Failed stage: Configure SRQL fixture database for tests [❌]
Failed test name: ""
Failure summary:
The action failed because a required GitHub Actions secret was missing/empty:
- The job aborted with
SRQL_TEST_DATABASE_CA_CERT secret must be configured to verify SRQL fixture TLS.(log line 707),which caused
Process completed with exit code 1(line 708).Additional issue observed during
post-job cleanup (not the primary failure):
- Git cleanup warned
fatal: No url found for submodulepath </code>swift/FieldSurvey/LocalPackages/arrow-swift<code> in </code>.gitmodules<code>and exited 128 (lines 718-719),indicating an inconsistent/misconfigured submodule entry during cleanup.
Relevant error logs:
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2960#issuecomment-3979010774
Original created: 2026-03-01T03:50:13Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Add a catch-all to prevent crashes
Add a catch-all function clause to
format_compact_number/1that returns "0" fornon-numeric inputs to prevent potential
FunctionClauseErrorcrashes, restoringthe robust behavior of the previous
format_number/1function.elixir/web-ng/lib/serviceradar_web_ng_web/live/analytics_live/index.ex [1009-1011]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that removing the catch-all clause from the old
format_numberfunction introduces a regression, potentially causing crashes if non-numeric values are passed toformat_compact_number.Round floats before formatting
In
format_compact_number/1, replacetrunc()withround()when handling floats toprovide more intuitive rounding (e.g., 1.9K becomes "2K" instead of "1K").
elixir/web-ng/lib/serviceradar_web_ng_web/live/analytics_live/index.ex [1009]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 4
__
Why: The suggestion proposes changing
trunctoroundfor float formatting, which is a reasonable product/UI improvement, but it's a change in logic, not a bug fix, as the PR maintained the originaltruncbehavior.