feat: add repository health score dashboard card#731
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThe Dashboard component now computes a Repository Health Score from issue and pull request counts, derives a qualitative health status label using threshold ranges, and displays the score with a Material-UI LinearProgress bar in a new Paper section positioned before the existing charts. ChangesRepository Health Score Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🎉 Thank you @jainiksha for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/components/Dashboard.tsx (2)
138-145: ⚡ Quick winAdd accessibility attributes to the progress bar.
The
LinearProgresscomponent should include anaria-labeloraria-labelledbyattribute so screen readers can announce the current health score to users relying on assistive technology.♿ Add aria-label for accessibility
<LinearProgress variant="determinate" value={healthScore} + aria-label={`Repository health score: ${healthScore} out of 100`} sx={{ height: 12, borderRadius: 5, }} />🤖 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/components/Dashboard.tsx` around lines 138 - 145, The LinearProgress usage in Dashboard should include an accessibility attribute so screen readers can announce the health score; update the LinearProgress element (in the Dashboard component where LinearProgress and value={healthScore} are used) to add either aria-label or aria-labelledby that describes the control and references the displayed health score (e.g., "Health score" or link to a nearby label element), ensuring the attribute reflects the healthScore value for assistive tech.
81-88: 💤 Low valueEliminate duplicated threshold logic.
The threshold checks for healthScore (≥80, ≥60, ≥40) are duplicated in two places: once for computing
healthStatus(lines 81-88) and again for selecting the color (lines 126-133). If thresholds change, you must update both locations.♻️ Refactor to use a single threshold-to-style mapping
+const getHealthStyle = (score: number) => { + if (score >= 80) return { status: "Excellent", color: "success.main" }; + if (score >= 60) return { status: "Good", color: "info.main" }; + if (score >= 40) return { status: "Moderate", color: "warning.main" }; + return { status: "Poor", color: "error.main" }; +}; + +const { status: healthStatus, color: healthColor } = getHealthStyle(healthScore); -const healthStatus = - healthScore >= 80 - ? "Excellent" - : healthScore >= 60 - ? "Good" - : healthScore >= 40 - ? "Moderate" - : "Poor";Then update the Typography component:
<Typography variant="h6" - color={ - healthScore >= 80 - ? "success.main" - : healthScore >= 60 - ? "info.main" - : healthScore >= 40 - ? "warning.main" - : "error.main" - } + color={healthColor} > Status: {healthStatus} </Typography>Also applies to: 126-133
🤖 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/components/Dashboard.tsx` around lines 81 - 88, The duplicated threshold logic for deriving textual status and color should be centralized: create a shared helper (e.g., getHealthCategory or healthCategoryFromScore) that takes healthScore and returns an object with the category string ("Excellent"/"Good"/"Moderate"/"Poor") and the associated color; replace the inline ternary that sets healthStatus and the separate color-selection logic used in the Typography component with calls to this helper so both the label and color come from the same source of truth (update places referencing healthStatus and the Typography color selection to use the helper's returned values).
🤖 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 `@src/components/Dashboard.tsx`:
- Around line 76-79: The current healthScore calculation using
totalContributions is misleading; replace it with a composite score computed
from ratios (not raw counts). Compute metrics like issueResolutionRate =
closedIssues / totalIssues, openIssueRatio = openIssues / totalIssues,
prMergeRate = mergedPrs / totalPrs, contributorActivity = recentContributorCount
/ totalContributors, and recencyScore from lastCommitDate; then weight and
combine these into a single healthScore (e.g., weighted sum normalized to 0–100)
and update the code that references healthScore and totalContributions so that
healthScore uses these new ratio variables instead of
Math.round((totalContributions / 50) * 100). Ensure you handle divide-by-zero
(fallbacks when totalIssues or totalPrs are 0) and update any UI labels that
describe the metric.
---
Nitpick comments:
In `@src/components/Dashboard.tsx`:
- Around line 138-145: The LinearProgress usage in Dashboard should include an
accessibility attribute so screen readers can announce the health score; update
the LinearProgress element (in the Dashboard component where LinearProgress and
value={healthScore} are used) to add either aria-label or aria-labelledby that
describes the control and references the displayed health score (e.g., "Health
score" or link to a nearby label element), ensuring the attribute reflects the
healthScore value for assistive tech.
- Around line 81-88: The duplicated threshold logic for deriving textual status
and color should be centralized: create a shared helper (e.g., getHealthCategory
or healthCategoryFromScore) that takes healthScore and returns an object with
the category string ("Excellent"/"Good"/"Moderate"/"Poor") and the associated
color; replace the inline ternary that sets healthStatus and the separate
color-selection logic used in the Typography component with calls to this helper
so both the label and color come from the same source of truth (update places
referencing healthStatus and the Typography color selection to use the helper's
returned values).
🪄 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
Run ID: f53814f2-5f98-4a07-aa5d-71c608cc9fbc
📒 Files selected for processing (1)
src/components/Dashboard.tsx
| const healthScore = Math.min( | ||
| 100, | ||
| Math.round((totalContributions / 50) * 100) | ||
| ); |
There was a problem hiding this comment.
The algorithm does not measure actual repository health.
The current implementation uses raw totals (totalIssues + totalPrs) regardless of state, which produces misleading results. A repository with 1000 open, unresolved issues would score "Excellent" (100/100), but that indicates poor health, not good health. Additionally, cumulative totals from the GitHub search API don't reflect current activity or maintenance quality.
Issue #719 requires analyzing:
- Issue resolution rate (closed/total)
- Pull request merge rate
- Open vs closed issues ratio
- Contributor activity trends
- Repository update frequency
Consider refactoring to compute ratios and rates instead of raw counts. For example:
issueResolutionRate = closedIssues / totalIssuesopenIssueRatio = openIssues / totalIssues- Weight and combine these metrics into a composite score
🤖 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/components/Dashboard.tsx` around lines 76 - 79, The current healthScore
calculation using totalContributions is misleading; replace it with a composite
score computed from ratios (not raw counts). Compute metrics like
issueResolutionRate = closedIssues / totalIssues, openIssueRatio = openIssues /
totalIssues, prMergeRate = mergedPrs / totalPrs, contributorActivity =
recentContributorCount / totalContributors, and recencyScore from
lastCommitDate; then weight and combine these into a single healthScore (e.g.,
weighted sum normalized to 0–100) and update the code that references
healthScore and totalContributions so that healthScore uses these new ratio
variables instead of Math.round((totalContributions / 50) * 100). Ensure you
handle divide-by-zero (fallbacks when totalIssues or totalPrs are 0) and update
any UI labels that describe the metric.
Related Issue
Description
Added a Repository Health Score card with status indicators and a progress bar to provide a quick overview of repository activity.
How Has This Been Tested?
Type of Change
Summary by CodeRabbit