fix: update analytical model to include total repositories and adjust…#94
Conversation
… related components
Walkthrough
ChangesTotal repos analytics flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
🤖 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/services/analytics.js`:
- Around line 40-56: The `buildAnalyticalModel` flow is computing `healthScore`
and `busFactor` for `totalRepos` using incomplete `contribsPerRepo` data from
`AppContext.jsx`’s `explore()` subset, so repos outside that subset get treated
as having zero contributors. Fix this by either ensuring contributor data is
available for every repo in `totalRepos` (or fetching it where needed) or by
changing `computeHealthScore`/`computeBusFactor` handling in `analytics.js` so
missing contributor data is distinguished from truly empty data and does not
silently default to zero. Keep the logic aligned with `buildAnalyticalModel`,
`computeHealthScore`, and `computeBusFactor` so downstream `OverviewPage` and
`RepositoriesPage` sorting reflects actual data availability.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b0c628d3-5d15-4c21-bea9-e46564ca5465
📒 Files selected for processing (4)
src/context/AppContext.jsxsrc/pages/OverviewPage.jsxsrc/pages/RepositoriesPage.jsxsrc/services/analytics.js
| export function buildAnalyticalModel(orgs, reposPerOrg, contribsPerRepo, totalReposPerOrg) { | ||
| const allRepos = [] | ||
| const contributorMap = {} | ||
| const totalRepos = []; | ||
|
|
||
| orgs.forEach(org => { | ||
| const repos = reposPerOrg[org.login] || [] | ||
| const total = totalReposPerOrg[org.login] || []; | ||
|
|
||
| total.forEach(repo => { | ||
| const key = `${org.login}/${repo.name}` | ||
| const contribs = contribsPerRepo[key] || [] | ||
| const health = computeHealthScore(repo, contribs.length) | ||
| const activityClassification = computeActivityClassification(repo) | ||
| const bf = computeBusFactor(contribs) | ||
| totalRepos.push({ ...repo, orgLogin: org.login, contributors: contribs, healthScore: health, activityClassification: activityClassification, busFactor: bf }) | ||
| }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Health score/bus factor are computed with incomplete contributor data for most of totalRepos.
total (from totalReposPerOrg) contains all repos per org, but contribsPerRepo is only ever populated for the reduced "top" list built in AppContext.jsx's explore() (getTopRepositories(...,10) for non-PAT users, or the full list only when a PAT is present). For every repo in total that isn't in that top subset, contribs resolves to [], so:
computeHealthScore's contributor-diversity term (30% weight) is always0, capping the score near ~70 regardless of actual contributor activity.computeBusFactor([])always returns{ factor: 0, risk: 'unknown' }.
This directly affects OverviewPage's health-sorted topRepos and RepositoriesPage's default health-sorted table (both driven by model.totalRepos), which is exactly the “all repositories” feature this PR is meant to introduce.
💡 Possible directions
- Fetch contributor counts for all repos (may be rate-limit prohibitive without a PAT — note the 60 req/hr GitHub default shown in the product).
- Or reweight
computeHealthScoreto redistribute the diversity weight when contributor data is unavailable, rather than silently defaulting to 0. - At minimum, mark repos lacking contributor data so downstream UI can distinguish "no data" from "poor diversity".
🤖 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/services/analytics.js` around lines 40 - 56, The `buildAnalyticalModel`
flow is computing `healthScore` and `busFactor` for `totalRepos` using
incomplete `contribsPerRepo` data from `AppContext.jsx`’s `explore()` subset, so
repos outside that subset get treated as having zero contributors. Fix this by
either ensuring contributor data is available for every repo in `totalRepos` (or
fetching it where needed) or by changing `computeHealthScore`/`computeBusFactor`
handling in `analytics.js` so missing contributor data is distinguished from
truly empty data and does not silently default to zero. Keep the logic aligned
with `buildAnalyticalModel`, `computeHealthScore`, and `computeBusFactor` so
downstream `OverviewPage` and `RepositoriesPage` sorting reflects actual data
availability.
Screenshots/Recordings:
Before: -


After: -


Additional Notes:
Make changes to include all the repo for an organization and show states for all the organizations, instead of top repo.
Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.
Summary by CodeRabbit
New Features
Bug Fixes