From 1336341be7c07bc9df960a9467583a9ea591ca1c Mon Sep 17 00:00:00 2001 From: Adam Rensel Date: Wed, 5 May 2021 16:10:41 -0400 Subject: [PATCH] Rework api requests to be parallelized --- .github/workflows/src/index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/src/index.js b/.github/workflows/src/index.js index cc28aaca..980e99c7 100644 --- a/.github/workflows/src/index.js +++ b/.github/workflows/src/index.js @@ -35,21 +35,25 @@ const actionEvent = require('./app/action-event.js'); const educationWeb = require('./app/education-web.js'); (async ()=>{ - const result = await educationWeb.hasPack() + const results = await Promise.all([ + octokit.fetchPr(actionEvent.pullRequest?.number), + airtable.userParticipated2020(pull.author.name), + educationWeb.hasPack(), + airtable.fetch2021Graduate(pull.author.name) + ]) - console.log(result) - return - - - console.log(actionEvent.pullRequest) - const pull = await octokit.fetchPr(actionEvent.pullRequest?.number) + const pull = results[0] + const user2021 = results[3] // checks - const user2020 = await airtable.userParticipated2020(pull.author.name) - // const hasSdp = TODO + // graduated already in 2020? + const user2020 = results[1] + + // approved for the student/teacher development pack + const hasSdp = results[2] - const user2021 = await airtable.fetch2021Graduate(pull.author.name) + // Has the user completed the shipping form? (address must exist for the form to be submitted) const completedShippingForm = user2021.get("Address Line 1").length > 0 // pull.files TODO @@ -58,7 +62,7 @@ const educationWeb = require('./app/education-web.js'); // pull.body // const markdownValid = TODO - // const userAgreesCoc = user2021.aggreesToCoc TODO + const userAgreesCoc = user2021.get("Code of Conduct").length > 0 if(user2020) { console.log("user already Participated in 2020") -- knotmirror 0.0.1