Skip to content

fix(analytics): fix bus factor calculation on contributors page (#230) - #231

Closed
Dotify71 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Dotify71:fix/bus-factor-metric
Closed

Dotify71 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Dotify71:fix/bus-factor-metric

Conversation

@Dotify71

@Dotify71 Dotify71 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Addressed Issues:

Fixes #230

Screenshots/Recordings:

N/A (covered by automated unit tests)

Additional Notes:

  • Resolves the issue where computeBusFactor in src/services/analytics.js only checked c.contributions, whereas aggregate contributor objects in model.contributors store contributions under totalContribs.
  • Added helper fallback c.contributions ?? c.totalContribs ?? 0 in computeBusFactor so it seamlessly handles both raw repo-level contributor objects and organization-level analytical model contributor objects.
  • Added unit test in src/services/analytics.healthMetrics.test.js to ensure contributor objects with totalContribs calculate the bus factor properly.
  • All 45 unit tests pass (vitest --run).

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

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

  • Bug Fixes

    • Bus factor calculations now handle contributor totals represented as numbers or as objects using either supported contribution field.
    • Risk assessments remain accurate across these contributor data formats, including when contributions are split 60/40.
  • Tests

    • Added coverage for numeric contributor totals and alternate contribution fields, including a 60/40 split.

@github-actions github-actions Bot added bug Something isn't working javascript JavaScript/TypeScript changes tests Test changes size/S 11-50 lines changed external-contributor External contributor labels Sep 13, 2026
@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: AOSSIE-Org/OrgExplorer/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 666cd706-331f-4cc3-9758-8a6a3186ca5a

📥 Commits

Reviewing files that changed from the base of the PR and between 133840d and 3e560b4.

📒 Files selected for processing (1)
  • src/services/analytics.healthMetrics.test.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

computeBusFactor now reads counts from numeric entries and contributor objects with contributions or totalContribs. Tests cover a 60/40 split in both object and numeric input forms.

Changes

Bus factor metric fix

Layer / File(s) Summary
Contributor count normalization and regression coverage
src/services/analytics.js, src/services/analytics.healthMetrics.test.js
computeBusFactor uses a shared getCount helper for total and cumulative counts. Tests expect { factor: 1, risk: 'critical' } for 60/40 inputs represented as totalContribs objects or numbers.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested labels: Typescript Lang

Suggested reviewers: prithvijitbose

Merge Risk: ⚪ Minimal · up to 3e560

This change adds numeric contributor-count support without introducing a concrete regression. No new merge blocker was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 3e560

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/services/analytics.js: In computeBusFactor, a new getCount helper extracts a contributor's count from a numeric value or from either the contributions or totalContribs property, and the total reduction and the loop accumulation now use it; the previous behavior assumed every contributor was an object with a contributions field.
  • observed — Modified behavior in src/services/analytics.healthMetrics.test.js: Updated the totalContribs test contributors to include login fields; the expected result for the 60/40 split remains { factor: 1, risk: 'critical' }.
  • observed — Modified behavior in src/services/analytics.healthMetrics.test.js: Added a test expecting computeBusFactor([60, 40]) to return { factor: 1, risk: 'critical' }.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing the bus factor calculation in the analytics contributors page. It matches the implementation and PR objective.
Linked Issues check ✅ Passed The change satisfies the coding requirements in issue #230. computeBusFactor now reads contributions and totalContribs, and it retains support for numeric entries. The normalized count is used f…
Out of Scope Changes check ✅ Passed The changes stay within issue #230. They modify only bus factor count handling and focused unit tests. The requested screen recording is a non-coding task and does not affect this assessment.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

A rabbit checks the counts in rows,
Where commit totals gently grow.
Numbers hop and fields align,
The split returns a factor fine.
The tests now mark the path ahead.

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Sep 13, 2026
@Ri1tik

Ri1tik commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Add a screen-recording here.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them:
https://www.youtube.com/watch?v=Sqsz1-o7nXk

@Dotify71
Dotify71 force-pushed the fix/bus-factor-metric branch from 133840d to 3e560b4 Compare October 2, 2026 05:30
@github-actions github-actions Bot added size/S 11-50 lines changed and removed PR has merge conflicts size/S 11-50 lines changed labels Oct 2, 2026
@Dotify71

Dotify71 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Verification Recording

Screen.Recording.2026-10-03.at.12.55.13.AM.mov

@Dotify71

Dotify71 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

This bug was resolved on main and deployed to production via PR #277. Closing this out since it is now working as expected on live!

@Dotify71 Dotify71 closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working external-contributor External contributor javascript JavaScript/TypeScript changes size/S 11-50 lines changed tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Bus Factor metric on Contributors page always evaluates to 0 (UNKNOWN) due to property mismatch

2 participants