From 25c4f932f521cd80f631985702e8519c80da19f4 Mon Sep 17 00:00:00 2001 From: Esteban Dalel R Date: Tue, 14 Nov 2023 15:14:58 -0500 Subject: [PATCH] Make calls to other services concurrent (#375) --- app/api/actions/github/route.ts | 91 ++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/app/api/actions/github/route.ts b/app/api/actions/github/route.ts index 32fd539c..ff6cdf81 100644 --- a/app/api/actions/github/route.ts +++ b/app/api/actions/github/route.ts @@ -413,48 +413,55 @@ export async function POST(request: Request) { repoName: repo, }); textToWrite += randomText(); - - // Detect console.logs and its equivalent in other languages - await detectConsoleLogs({ - prTitle: title, - businessLogicSummary, - repo, - owner, - issue_number: number, - installationId, - reqUrl: request.url, - reqEmail: req.email, - }); - - // Make Watermelon Review the PR's business logic here by comparing the title with the AI-generated summary - await labelPullRequest({ - prTitle: title, - businessLogicSummary, - repo, - owner, - issue_number: number, - installationId, - reqUrl: request.url, - reqEmail: req.email, + Promise.all([ + // Detect console.logs and its equivalent in other languages + detectConsoleLogs({ + prTitle: title, + businessLogicSummary, + repo, + owner, + issue_number: number, + installationId, + reqUrl: request.url, + reqEmail: req.email, + }), + // Make Watermelon Review the PR's business logic here by comparing the title with the AI-generated summary + labelPullRequest({ + prTitle: title, + businessLogicSummary, + repo, + owner, + issue_number: number, + installationId, + reqUrl: request.url, + reqEmail: req.email, + }), + addActionLog({ + randomWords, + github, + jira, + slack, + notion, + linear, + asana, + textToWrite, + businessLogicSummary, + owner, + repo, + number, + payload: req, + count, + watermelon_user, + }), + ]).catch((error) => { + failedPosthogTracking({ + url: request.url, + error: error.message, + email: req.email, + }); + return console.error("posting comment error", error); }); - await addActionLog({ - randomWords, - github, - jira, - slack, - notion, - linear, - asana, - textToWrite, - businessLogicSummary, - owner, - repo, - number, - payload: req, - count, - watermelon_user, - }); // Fetch all comments on the PR const comments = await octokit.request( "GET /repos/{owner}/{repo}/issues/{issue_number}/comments?sort=created&direction=desc", @@ -469,7 +476,9 @@ export async function POST(request: Request) { ); // Find our bot's comment let botComment = comments.data.find((comment) => { - return comment?.user?.login.includes("watermelon-copilot-for-code-review"); + return comment?.user?.login.includes( + "watermelon-copilot-for-code-review" + ); }); if (botComment?.id) { // Update the existing comment