fix(changelog): break pagination when commits pass date cutoff
Build & Deploy / build-and-deploy (push) Successful in 2m13s

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 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-03-31 13:33:13 +02:00
parent 139e4b608b
commit acaff70cfe
+6 -2
View File
@@ -181,10 +181,14 @@ function changelogApp() {
if (!r.ok) break; if (!r.ok) break;
const commits = await r.json(); const commits = await r.json();
if (!Array.isArray(commits) || commits.length === 0) break; if (!Array.isArray(commits) || commits.length === 0) break;
const sinceDate = since ? new Date(since) : null;
let pastCutoff = false;
for (const c of commits) { for (const c of commits) {
const lines = (c.commit?.message || '').split('\n'); const lines = (c.commit?.message || '').split('\n');
const title = lines[0]; const title = lines[0];
const body = lines.slice(1).join('\n').trim(); 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({ allCommits.push({
sha: c.sha.slice(0, 7), sha: c.sha.slice(0, 7),
fullSha: c.sha, fullSha: c.sha,
@@ -193,12 +197,12 @@ function changelogApp() {
url: c.html_url, url: c.html_url,
repoUrl: `${GITEA_URL}/${GITEA_ORG}/${repo}`, repoUrl: `${GITEA_URL}/${GITEA_ORG}/${repo}`,
repoName: repo, repoName: repo,
date: c.created || c.commit?.author?.date, date,
author: c.commit?.author?.name || '', author: c.commit?.author?.name || '',
commitCategory: categorizeCommit(title), commitCategory: categorizeCommit(title),
}); });
} }
if (commits.length < limit) break; if (commits.length < limit || pastCutoff) break;
page++; page++;
} }
})); }));