From acaff70cfefe75916baea024e208aead272fa4de Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:33:13 +0200 Subject: [PATCH] fix(changelog): break pagination when commits pass date cutoff Gitea's commits API ignores the 'since' param, returning all 360+ commits regardless. Added client-side date filtering: skip commits older than the cutoff and break pagination early once a page contains commits past the cutoff. Prevents fetching 7+ pages on every load. Co-Authored-By: Claude Sonnet 4.6 --- changelog.njk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/changelog.njk b/changelog.njk index 121ed50..95fbd00 100644 --- a/changelog.njk +++ b/changelog.njk @@ -181,10 +181,14 @@ function changelogApp() { if (!r.ok) break; const commits = await r.json(); if (!Array.isArray(commits) || commits.length === 0) break; + const sinceDate = since ? new Date(since) : null; + let pastCutoff = false; for (const c of commits) { const lines = (c.commit?.message || '').split('\n'); const title = lines[0]; const body = lines.slice(1).join('\n').trim(); + const date = c.created || c.commit?.author?.date; + if (sinceDate && new Date(date) < sinceDate) { pastCutoff = true; continue; } allCommits.push({ sha: c.sha.slice(0, 7), fullSha: c.sha, @@ -193,12 +197,12 @@ function changelogApp() { url: c.html_url, repoUrl: `${GITEA_URL}/${GITEA_ORG}/${repo}`, repoName: repo, - date: c.created || c.commit?.author?.date, + date, author: c.commit?.author?.name || '', commitCategory: categorizeCommit(title), }); } - if (commits.length < limit) break; + if (commits.length < limit || pastCutoff) break; page++; } }));