Skip to content

Fix Dashboards/Metrics in Main View and Reports#29

Merged
homeles merged 2 commits intomainfrom
fix/dashboard-metrics-21
Mar 4, 2026
Merged

Fix Dashboards/Metrics in Main View and Reports#29
homeles merged 2 commits intomainfrom
fix/dashboard-metrics-21

Conversation

@lupita-hom
Copy link
Collaborator

Summary

Fixes multiple bugs in the Stats/Reports view and backend metrics pipeline.

Bugs Fixed

1. Weekly Activity Trend was using Math.random()

The trend chart was generating random data on every render instead of using actual workflow run dates. Now queries the last 7 days of runs and counts per day.

2. Duration formatting was wrong (seconds vs milliseconds)

A local formatDuration function at the bottom of RepositoryStats.jsx shadowed the correctly-imported one from statusHelpers.js. The local version treated millisecond values as seconds, showing wildly incorrect durations. Removed the local version and now uses the shared utility.

3. Missing avgDuration in repo stats

The backend MongoDB aggregation pipeline in calculateWorkflowStats didn't compute avgDuration per repository, so the Stats view always showed "N/A" for repository durations. Added $subtract + $avg to the pipeline.

4. Division by zero crashes

When totalRuns is 0 for an org or repo, calculating success rate would produce NaN or crash. Added guards in 3 places.

5. Weekly Activity Trend chart was never rendered

trendData was computed but the Line chart was never included in the JSX. Now rendered side-by-side with the Success Rates chart.

6. recentRuns query was limited to 5

The backend only returned 5 recent runs, not enough for a 7-day trend. Now queries all runs from the last 7 days.

Files Changed

  • client/src/features/stats/RepositoryStats.jsx — all frontend fixes
  • server/src/services/workflowService.js — backend aggregation + query fix

Fixes #21

- Fix Weekly Activity Trend using Math.random() instead of actual data
- Remove local formatDuration that shadowed the correct imported version
  (was treating ms values as seconds, showing wrong durations)
- Add avgDuration to backend repo stats aggregation pipeline
- Fix division-by-zero crashes when totalRuns is 0
- Render the Weekly Activity Trend chart (was computed but never shown)
- Expand recentRuns query to 7 days for meaningful trend data
- Layout success rates + trend side-by-side for better use of space

Fixes #21
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@homeles homeles requested review from Copilot and removed request for Copilot March 3, 2026 22:19
@homeles homeles merged commit f43c7d7 into main Mar 4, 2026
12 checks passed
@homeles homeles deleted the fix/dashboard-metrics-21 branch March 4, 2026 15:13
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.

🐛 Fix Dashboards/Metrics in Main View and Reports

2 participants