Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions apps/slack-bot/src/services/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,22 @@ export async function listPRs(repo, token, headPrefix) {
}

/**
* Return the latest editorial-loop batch of draft blog PRs, ordered to match
* Return the latest editorial-loop batch of open blog PRs, ordered to match
* the numbered Slack post (idea 1 first). Groups by the YYYY-MM-DD prefix
* embedded in the `blog/<date>-<slug>` branch name and picks the most recent
* date, then sorts that group by PR creation time ascending.
* date, then sorts that group by PR creation time ascending. Includes both
* draft and ready-for-review PRs since pr-creator.js opens them as the latter.
*/
export async function getLatestIdeaBatch(repo, token) {
const prs = await ghFetch(`/repos/${repo}/pulls?state=open&per_page=50`, {}, token);
const dateOf = (pr) => {
const m = pr.head.ref.match(/^blog\/(\d{4}-\d{2}-\d{2})-/);
return m ? m[1] : null;
};
const drafts = prs.filter(pr => pr.draft && dateOf(pr));
if (drafts.length === 0) return [];
const latestDate = drafts.map(dateOf).sort().pop();
return drafts
const blogPRs = prs.filter(pr => dateOf(pr));
if (blogPRs.length === 0) return [];
const latestDate = blogPRs.map(dateOf).sort().pop();
return blogPRs
.filter(pr => dateOf(pr) === latestDate)
.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
}
Expand Down
Loading