You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Performance] /api/notifications/discord-sync fetches every discord user in a single query — cron truncates #3163
no .range(), no .limit(), no ordering. line 36 then serially loops with for (const user of users) and for each one calls fetchPublicStreak and possibly fetchPublicContributions (github API roundtrips) plus a supabase update. so the query size AND the loop time both scale with total discord users.
failure scenario: this cron runs hourly. once discord users cross a few hundred, the outer loop cannot finish inside the vercel function timeout and the whole batch is truncated. users at the end of the query never get notifications. worse, the initial supabase read pulls all rows including muted / already-notified users that get skipped later at lines 60-77 anyway, so most of the payload is wasted.
Proposed Fix
page the users query in batches of 50 same as src/app/api/cron/sync/route.ts:38-128
push the "which users need a notification this hour" filters into the SQL where clause: filter on last_discord_notification_at < now() - interval '20 hours' and discord_muted_until is null or discord_muted_until < now() so we do not fetch users we will just skip
optionally split streak-at-risk vs weekly-summary into separate scheduled runs so the sunday load does not stack
I would like to work on this under GSSoC 26. please assign!
for labels i think gssoc + level2 + type:performance fits here.
Activity
github-actions commentedon Jul 19, 2026
✅ Closed as completed!
If DevTrack has been useful, a ⭐ star on the repo helps the project grow and reach more developers.
perf: paginate discord-sync users query + push filters into SQL (Priy…