Skip to content

Commit

Permalink
Make ancestor and descendant requests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMatase committed Dec 1, 2024
1 parent 12a9168 commit 0796088
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions source/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ export async function generateResults(
repo: string,
prNumber: number,
): Promise<Results> {
let ancestorPrs = new Array<PrResponseData>();
let descendantPrs = new Array<PrResponseData>();

const requestedPr = await getPr(octokit, owner, repo, prNumber);

// Base <= head
Expand All @@ -133,19 +130,10 @@ export async function generateResults(
// ancestors are where their head is our base
// descendants are where their base is our head

// TODO: do these queries in parallel
ancestorPrs = await fetchAllPrsForRepoWithHead(
octokit,
owner,
repo,
requestedPr.base.label,
);
descendantPrs = await fetchAllPrsForRepoWithBase(
octokit,
owner,
repo,
requestedPr.head.ref,
); // Base arg is just the branch name
const [ancestorPrs, descendantPrs] = await Promise.all([
fetchAllPrsForRepoWithHead(octokit, owner, repo, requestedPr.base.label),
fetchAllPrsForRepoWithBase(octokit, owner, repo, requestedPr.head.ref),
]);

return {
ancestorPrs: ancestorPrs.map((x) => getInfo(x)),
Expand Down

0 comments on commit 0796088

Please sign in to comment.