Describe the Bug
The /api/goals/sync endpoint fetches weekly commit count from the GitHub Search API and writes ghData.total_count directly as the goal's current value.
Relevant code in src/app/api/goals/sync/route.ts:
const ghData = (await ghRes.json()) as { total_count: number };
const commitCount = ghData.total_count;
await supabaseAdmin
.from('goals')
.update({ current: commitCount, last_synced_at: now })
.in('id', ids);
This has two distinct problems:
Problem 1: GitHub hard-caps total_count at 1000
The GitHub Search API documents that total_count is capped at 1000 regardless of actual results. For prolific contributors this means:
- A user with 1200 commits this week gets
current = 1000, not 1200
- A user with a goal target of 50 commits can have
current set to 1000, making the goal appear 20x over-completed
Problem 2: All commit goals receive the same aggregate count
The sync query uses a single total across all repos and all timeframes. A user with two separate goals:
- "50 commits to frontend repo this week"
- "20 commits to backend repo this week"
...both get overwritten with the same combined cross-repository total_count. Per-repo goal tracking is completely broken.
Steps to Reproduce
- Create two commit-based weekly goals targeting different values
- Make more than 1000 commits in a week (or observe with any active multi-repo workflow)
- Trigger goal sync
- Both goals show the same
current value; goals with a target below total_count appear falsely completed
Expected Behavior
- Commit count used for goal progress should come from paginating
data.items (actual returned results) rather than trusting total_count
- For per-repo goals, the sync query should be scoped to the goal's target repository, not a cross-all-repos aggregate
Screenshots / Logs
GitHub API response excerpt:
{
"total_count": 1000,
"incomplete_results": true,
"items": [...]
}
When incomplete_results: true, the real count exceeds 1000 but total_count is capped.
Environment
- OS: Any
- Node version: 18+
- Browser: Any
Additional Context
Existing issue #361 documents a similar cap problem with the contributions widget. The same root cause applies here in the goals sync path.
I am happy to work on this if it can be assigned to me.
Describe the Bug
The
/api/goals/syncendpoint fetches weekly commit count from the GitHub Search API and writesghData.total_countdirectly as the goal'scurrentvalue.Relevant code in
src/app/api/goals/sync/route.ts:This has two distinct problems:
Problem 1: GitHub hard-caps total_count at 1000
The GitHub Search API documents that
total_countis capped at 1000 regardless of actual results. For prolific contributors this means:current = 1000, not 1200currentset to 1000, making the goal appear 20x over-completedProblem 2: All commit goals receive the same aggregate count
The sync query uses a single total across all repos and all timeframes. A user with two separate goals:
...both get overwritten with the same combined cross-repository
total_count. Per-repo goal tracking is completely broken.Steps to Reproduce
currentvalue; goals with atargetbelowtotal_countappear falsely completedExpected Behavior
data.items(actual returned results) rather than trustingtotal_countScreenshots / Logs
GitHub API response excerpt:
{ "total_count": 1000, "incomplete_results": true, "items": [...] }When
incomplete_results: true, the real count exceeds 1000 buttotal_countis capped.Environment
Additional Context
Existing issue #361 documents a similar cap problem with the contributions widget. The same root cause applies here in the goals sync path.
I am happy to work on this if it can be assigned to me.