Skip to content

Fix duplicate new contributors appearing across multiple months#609

Merged
castrojo merged 1 commit intomainfrom
fix/duplicate-new-contributors
Jan 31, 2026
Merged

Fix duplicate new contributors appearing across multiple months#609
castrojo merged 1 commit intomainfrom
fix/duplicate-new-contributors

Conversation

@castrojo
Copy link
Contributor

Summary

  • Fixes critical bug where contributors appeared as "new" in multiple consecutive months
  • Root cause: Date boundary overlap in historical contributor query
  • Solution: Subtract 1ms from historical query endpoint to ensure strict separation

Problem Details

Contributors were incorrectly marked as "New Lights" (first-time contributors) in multiple months:

Example duplicates found:

  • KiKaraage: Marked as new in both Dec 2025 and Jan 2026
  • coxde: Marked as new in both Dec 2025 and Jan 2026
  • sebjag: Marked as new in both Dec 2025 and Jan 2026
  • theMimolet: Marked as new in both Dec 2025 and Jan 2026
  • jumpyvi: Marked as new in both Dec 2025 and Jan 2026

Root Cause

Date boundary overlap in scripts/lib/contributor-tracker.mjs:

Before:

// Historical query: 2024-01-01 to reportStartDate (inclusive <=)
// Current report:  reportStartDate to reportEndDate (inclusive >=)
// Problem: reportStartDate included in BOTH ranges!

PRs merged at exactly 2026-01-01 00:00:00.000Z were counted in both the historical set AND the current report period.

Solution

Subtract 1 millisecond from historical query endpoint:

const historicalEnd = new Date(beforeDate.getTime() - 1);
// Historical: 2024-01-01 to 2025-12-31T23:59:59.999Z (excludes Jan 1)
// Current:    2026-01-01T00:00:00.000Z to 2026-01-31T23:59:59.999Z
// Result: No overlap!

Verification

Ran comprehensive verification showing:

Zero duplicates between December and January new contributors
All 16 December new contributors correctly categorized in January:

  • 7 active as returning "Wayfinders" (without gold highlight)
  • 9 inactive (not listed)

Verified examples:

  • ✅ KiKaraage: Dec (new) → Jan (returning, no highlight)
  • ✅ coxde: Dec (new) → Jan (returning, no highlight)
  • ✅ sebjag: Dec (new) → Jan (returning, no highlight)
  • ✅ theMimolet: Dec (new) → Jan (returning, no highlight)
  • ✅ jumpyvi: Dec (new) → Jan (returning, no highlight)

Changes

  • scripts/lib/contributor-tracker.mjs: Fixed date boundary logic with 1ms subtraction
  • reports/2025-12-31-report.mdx: Regenerated with corrected logic
  • reports/2026-01-31-report.mdx: Regenerated with corrected logic

Impact

  • Future reports: Will automatically use corrected logic (no code changes needed)
  • Historical reports: Can be regenerated with --month=YYYY-MM flag to apply fix
  • No breaking changes: Report format and structure remain identical

Testing

# Regenerate reports to verify fix
export GITHUB_TOKEN=$(gh auth token)
node scripts/generate-report.mjs --month=2025-12
node scripts/generate-report.mjs --month=2026-01

# Verify no duplicates
grep "highlight={true}" reports/2025-12-31-report.mdx | wc -l  # 16 new
grep "highlight={true}" reports/2026-01-31-report.mdx | wc -l  # 10 new (all different)

Fix date boundary overlap bug where contributors appeared as 'new' in
multiple months. The issue occurred because the historical contributor
query used an inclusive endpoint (<=) which caused PRs merged at the
exact report start time (e.g., 2026-01-01 00:00:00.000Z) to be counted
in both the historical set AND the current report period.

Root cause:
- Historical query: 2024-01-01 to reportStartDate (inclusive)
- Current report: reportStartDate to reportEndDate (inclusive)
- Result: reportStartDate overlapped in both ranges

Solution:
Subtract 1 millisecond from historical query endpoint to ensure strict
boundary separation:
- Historical: 2024-01-01 to (reportStartDate - 1ms)
- Current: reportStartDate to reportEndDate

Verified fix:
- December 2025: 16 new contributors (KiKaraage, coxde, sebjag, etc.)
- January 2026: 10 new contributors (all different people)
- No overlap: December new contributors correctly show as returning in January

Changes:
- scripts/lib/contributor-tracker.mjs: Subtract 1ms from beforeDate
- reports/2025-12-31-report.mdx: Regenerated with fixed logic
- reports/2026-01-31-report.mdx: Regenerated with fixed logic

Assisted-by: Claude Sonnet 4.5 via GitHub Copilot
@castrojo castrojo enabled auto-merge January 30, 2026 00:00
@castrojo castrojo disabled auto-merge January 31, 2026 03:42
@castrojo castrojo merged commit 545507c into main Jan 31, 2026
2 checks passed
@castrojo castrojo deleted the fix/duplicate-new-contributors branch January 31, 2026 03:43
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