mirror of
https://github.com/actions/stale.git
synced 2025-12-11 04:32:53 +00:00
Add RateLimit
This commit is contained in:
@@ -27,6 +27,8 @@ import {LoggerService} from '../services/logger.service';
|
||||
import {OctokitIssue} from '../interfaces/issue';
|
||||
import {retry} from '@octokit/plugin-retry';
|
||||
import {IState} from '../interfaces/state/state';
|
||||
import {IRateLimit} from '../interfaces/rate-limit';
|
||||
import {RateLimit} from './rate-limit';
|
||||
|
||||
/***
|
||||
* Handle processing of issues for staleness/closure.
|
||||
@@ -636,6 +638,16 @@ export class IssuesProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
async getRateLimit(): Promise<IRateLimit | undefined> {
|
||||
const logger: Logger = new Logger();
|
||||
try {
|
||||
const rateLimitResult = await this.client.rest.rateLimit.get();
|
||||
return new RateLimit(rateLimitResult.data.rate);
|
||||
} catch (error) {
|
||||
logger.error(`Error when getting rateLimit: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// handle all of the stale issue logic when we find a stale issue
|
||||
private async _processStaleIssue(
|
||||
issue: Issue,
|
||||
|
||||
Reference in New Issue
Block a user