-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(changelog): Fetch PRs by merge date instead of update date #18911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,11 +181,15 @@ async function fetchMergedPRs() { | |
| headers['Authorization'] = `Bearer ${GITHUB_TOKEN}`; | ||
| } | ||
|
|
||
| // Fetch recently merged PRs | ||
| const searchQuery = `repo:${REPO_OWNER}/${REPO_NAME} is:pr is:merged sort:updated-desc`; | ||
| const url = `https://api.github.com/search/issues?q=${encodeURIComponent(searchQuery)}&per_page=${PR_LIMIT}`; | ||
| // Limit to PRs merged in the last 30 days to avoid pulling in old PRs | ||
| // that were recently "updated" by bot comments or label changes | ||
| const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); | ||
| const mergedSince = thirtyDaysAgo.toISOString().split('T')[0]; | ||
|
|
||
| console.log('Fetching merged PRs...'); | ||
| const searchQuery = `repo:${REPO_OWNER}/${REPO_NAME} is:pr is:merged merged:>=${mergedSince}`; | ||
| const url = `https://api.github.com/search/issues?q=${encodeURIComponent(searchQuery)}&sort=created&order=desc&per_page=${PR_LIMIT}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong API sort misses mergesMedium Severity The search request sorts by Reviewed by Cursor Bugbot for commit 39445cb. Configure here. |
||
|
|
||
| console.log(`Fetching PRs merged since ${mergedSince}...`); | ||
|
|
||
| const response = await fetch(url, {headers}); | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The script fetches PRs sorted by creation date but then sorts by merge date. With a fixed limit of 50 PRs, recently merged but older PRs may be missed.
Severity: MEDIUM
Suggested Fix
Since the GitHub Search API does not support sorting by merge date, the script should be updated to use pagination. It should fetch all pull requests merged within the specified date range, page by page, and then perform the client-side sort by
merged_aton the complete, unfiltered dataset to ensure no entries are missed.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.