fix(changelog): break pagination when commits pass date cutoff
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 2m13s
All checks were successful
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:
@@ -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++;
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user