Skip to content

Fix inconsistent timezone handling in contributions API and StreakCalendar - #3237

Open
saurabhhhcodes wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
saurabhhhcodes:fix/devtrack-batch-1
Open

Fix inconsistent timezone handling in contributions API and StreakCalendar#3237
saurabhhhcodes wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
saurabhhhcodes:fix/devtrack-batch-1

Conversation

@saurabhhhcodes

Copy link
Copy Markdown
Contributor

Bug 1: Mixed timezone handling in contributions API route

fetchContributionsForAccount used toLocalDateStr() (local timezone) to format the since date for the GitHub API query, while every other route uses toISOString().slice(0, 10) (UTC). For users in negative UTC offsets this caused a one-day shift in the query window, making streak and contribution data disagree on which dates to include. Fixed by removing toLocalDateStr and using since.toISOString().slice(0, 10) consistently with the rest of the codebase.

Bug 2: StreakCalendar used local dates to look up UTC-keyed contribution data

The StreakCalendar component used toLocalDateStr() (local timezone) to construct the lookup key into the contribution data, but the data keys come from GitHub's API which always returns UTC dates (item.commit.author.date.slice(0, 10)). This caused commits to appear on wrong calendar cells for users whose local date differs from UTC. Fixed by renaming to toUtcDateStr and using toISOString().slice(0, 10) for both lookup and isToday comparison.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels Jul 25, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jul 25, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

This one is genuine work and I want it — unlike the bulk PRs, this fixes real bugs:

  1. Merged-PR count was wrong. data.items.filter(pr => pr.state === "closed") counted every closed PR as merged, so closed-unmerged PRs inflated the number. Your pr.pull_request?.merged_at != null is the correct check (and correctly uses != so it catches undefined too).
  2. Timezone consistency — swapping the local-date helper for toISOString().slice(0,10) matches GitHub's UTC commit dates.
  3. Pagination via the link header with Promise.allSettled, capped at 5 pages.

Two things before it can merge:

  • It conflicts with main. The branch is based on a much older commit (its ci.yml still uses npm and actions/checkout@v4), so please rebase onto current main and resolve.
  • Concurrency: the pagination fires up to 4 parallel Search API calls per user. GitHub's guidance is to make requests for a single user serially — Search has a low secondary rate limit. Please cap it to 2 concurrent, or fetch sequentially.

Rebase + that tweak and I'll merge it. This is the standard of work I want from you — please put your effort here rather than into bulk submissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants