Skip to content

Commit

Permalink
ci(response): use pagination for timeline events
Browse files Browse the repository at this point in the history
GitHub paginates responses with many results, which needs to be taken
into account as the number of events in an issue can be large.
  • Loading branch information
dundargoc authored May 7, 2023
1 parent 416f030 commit 1cbfed0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions .github/scripts/close_unresponsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ module.exports = async ({ github, context }) => {
const numbers = issues.data.map((e) => e.number);

for (const number of numbers) {
const timeline = await github.rest.issues.listEventsForTimeline({
owner: owner,
repo: repo,
issue_number: number,
});
const data = timeline.data.filter(labeledEvent);
const latest_response_label = data[data.length - 1];
const events = await github.paginate(
github.rest.issues.listEventsForTimeline,
{
owner: owner,
repo: repo,
issue_number: number,
},
(response) => response.data.filter(labeledEvent)
);

const latest_response_label = events[events.length - 1];

const created_at = new Date(latest_response_label.created_at);
const now = new Date();
const diff = now - created_at;
Expand Down

0 comments on commit 1cbfed0

Please sign in to comment.