Skip to content

fix: correct contributor growth calculations#96

Open
nehayadav827 wants to merge 1 commit into
seetadev:mainfrom
nehayadav827:fix/contributor-growth-weekly
Open

fix: correct contributor growth calculations#96
nehayadav827 wants to merge 1 commit into
seetadev:mainfrom
nehayadav827:fix/contributor-growth-weekly

Conversation

@nehayadav827

Copy link
Copy Markdown

Description

This PR fixes a data correctness issue in src/lib/data-processing.ts where contributorGrowth always returned a single hardcoded entry instead of a real per-week contributor growth breakdown.

This directly relates to the Builder Intelligence analytics layer described in Issue #68.


Problem

Previously, processData() returned:

contributorGrowth: [{
  week: new Date().toISOString().split('T')[0],
  newContributors: activeContributors,
  returningContributors: 0,
  totalActive: activeContributors
}]

This caused multiple analytics issues:

  • no weekly contributor growth history
  • returningContributors always remained 0
  • newContributors incorrectly used the all-time contributor count
  • charts received a single synthetic entry instead of week-by-week trends

Fix

Added calculateContributorGrowth() to:

  • sort program weeks chronologically
  • track contributor first appearances
  • distinguish new vs returning contributors
  • calculate per-week active contributor totals
  • return one contributor growth entry per program week

processData() now uses:

contributorGrowth: calculateContributorGrowth(csvData)

Changes

  • Added calculateContributorGrowth()
  • Replaced hardcoded contributor growth object
  • Added chronological weekly contributor tracking
  • Fixed returning contributor calculations
  • Kept implementation scoped to src/lib/data-processing.ts

Validation

A standalone local validation script was used during development to verify:

  • broken behaviour reproduction
  • correct weekly contributor aggregation
  • new vs returning contributor tracking
  • chronological ordering
  • edge-case handling

Validation result:

12 passed   0 failed

Validation Output

Screenshot 2026-05-25 104921

Also ran:

git diff --check

No formatting or whitespace issues were reported.


Additional Notes

Current repository checks still contain unrelated existing blockers:

  • npx tsc --noEmit --pretty false fails on existing test typing/fixture issues in src/lib/__tests__/utils.test.ts
  • npm test -- --runInBand src/lib/__tests__/utils.test.ts fails on an existing expectation mismatch unrelated to this change

No breaking changes introduced.


Checklist

  • I have tested this code
  • I have linked relevant issue(s)
  • I followed the code style of the project
  • I reviewed my own code

Relates to #68

@vercel

vercel Bot commented May 25, 2026

Copy link
Copy Markdown

@nehayadav827 is attempting to deploy a commit to the SEETA's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant