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 ea989a2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions 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 All @@ -92,13 +102,21 @@ export class RepositoryApi {
`Extracting all issue information from ${this.repo.owner}/${this.repo.repo}`,
);
do {
const query: IssueList = await this.api.graphql<IssueList>(
let query:IssueList;
try{
query = await this.api.graphql<IssueList>(
ISSUE_LIST_QUERY,
{
cursor,
...this.repo,
},
);
}catch(e){
this.logger.error(e as Error);
this.logger.warn(JSON.stringify(e));

throw e;
}
const totalPages =
Math.floor(query.repository.issues.totalCount / 100) + 1;
this.logger.info(`Querying page ${++currentPage}/${totalPages}`);
Expand Down

0 comments on commit ea989a2

Please sign in to comment.