* feat: show open boilerplate prs on dashboard fix: rest of boilerplate server changes fix: more fix: other * fix: update lib functions * fix: retrofitted one-off scripts * feat: added rateLimit for requests * fix: reduce time * fix: put limiter inside each route * fix: make client show when rated limited * fix: removed unused probot from app * fix: renamed folders * fix: consolidate config.js and constants.js * chore: update octokit to latest version * fix: remove invalid file * fix: refactored update-db.js * feat: add fcc logo * fix: logo url * fix: remove Home link * fix: change link colors * fix: added rate limiter to landing page * fix: ran npm install in client to create package-lock.json * fix: correct typo in doc Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> * fix: Replace favicon, Gitter => Discord Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * fix: add extra linting guidance to package.json * Ignore contributor app Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * fix: revert linting rules for client * fix: add skip_preflight_check=true for tests Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Kris Koishigawa <scissorsneedfoodtoo@gmail.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
const { Octokit } = require('@octokit/rest');
|
|
const {
|
|
github: { owner, secret }
|
|
} = require('../config');
|
|
|
|
const octokit = new Octokit({ auth: secret });
|
|
|
|
const getCount = async (repo, base) => {
|
|
const baseStr = base ? `+base:${base}` : '';
|
|
/* eslint-disable camelcase */
|
|
const {
|
|
data: { total_count: count }
|
|
} = await octokit.search
|
|
.issues({
|
|
q: `repo:${owner}/${repo}+is:open+type:pr${baseStr}`,
|
|
sort: 'created',
|
|
order: 'asc',
|
|
page: 1,
|
|
per_page: 1
|
|
})
|
|
.catch(err => console.log(err));
|
|
return count;
|
|
};
|
|
|
|
const getRange = async (repo, base) => {
|
|
let methodProps = {
|
|
owner,
|
|
repo,
|
|
state: 'open',
|
|
sort: 'created',
|
|
page: 1,
|
|
per_page: 1
|
|
};
|
|
if (base) {
|
|
methodProps = { ...methodProps, base };
|
|
}
|
|
let response = await octokit.pulls.list({
|
|
direction: 'asc',
|
|
...methodProps
|
|
});
|
|
// In the case there are no open PRs for repo
|
|
if (!response.data.length) {
|
|
return [null, null];
|
|
}
|
|
const firstPR = response.data[0].number;
|
|
response = await octokit.pulls.list({
|
|
direction: 'desc',
|
|
...methodProps
|
|
});
|
|
const lastPR = response.data[0].number;
|
|
return [firstPR, lastPR];
|
|
};
|
|
|
|
module.exports = { getCount, getRange };
|