Skip to content

Commit

Permalink
UNDO THIS - limit experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Apr 15, 2024
1 parent 1127b7a commit 52dc230
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/github/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,35 @@ export class RepositoryApi {
`Extracting all PR information from ${this.repo.owner}/${this.repo.repo}`,
);
do {
const query: PullRequestList = await this.api.graphql<PullRequestList>(
let query: PullRequestList
try{
query = await this.api.graphql<PullRequestList>(
PULL_REQUEST_LIST_QUERY,
{
cursor,
...this.repo,
},
);
this.logger.info(`Rate limits are ${JSON.stringify(query.rateLimit)}`);
}catch(e){
this.logger.error(e as Error);
this.logger.warn(JSON.stringify(e));

throw e;
}
const totalPages =
Math.floor(query.repository.pullRequests.totalCount / 100) + 1;
this.logger.info(`Querying page ${++currentPage}/${totalPages}`);
const { nodes, pageInfo } = query.repository.pullRequests;
prs.push(...nodes);
hasNextPage = pageInfo.hasNextPage;
cursor = pageInfo.endCursor;
/*
if(currentPage % 5 === 0){
this.logger.debug("Pausing for one minute to not hit secondary limits")
await new Promise<void>(resolve => setTimeout(() => resolve(), 60_000));
}
*/
if (query.rateLimit.remaining < 300) {
const {resetAt} = query.rateLimit;
this.logger.info(`About to reach limit. Limit resets at ${resetAt}. Waiting for ${secondsToTime(resetAt)}`);
Expand Down

0 comments on commit 52dc230

Please sign in to comment.