From 5ccfe90a20444a2a62bcd5b458e91c0ef2c6f1f0 Mon Sep 17 00:00:00 2001 From: Adam Rensel Date: Fri, 7 May 2021 14:44:24 -0400 Subject: [PATCH] Work out bugs in api services --- .github/workflows/src/app/action-event.js | 14 ++++---- .github/workflows/src/app/airtable.js | 15 ++++++-- .github/workflows/src/app/octokit.js | 43 +++++++++++------------ 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.github/workflows/src/app/action-event.js b/.github/workflows/src/app/action-event.js index 62029bae..1be14c99 100644 --- a/.github/workflows/src/app/action-event.js +++ b/.github/workflows/src/app/action-event.js @@ -3,15 +3,13 @@ const fs = require('fs') class ActionsEvent { constructor() { try { - console.log("path: " + process.env.GITHUB_EVENT_PATH) - this.eventData = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')) - // add the number back to the PR object - this.eventData.pull_request.number = this.eventData.number - this.pullRequest = this.eventData?.pull_request || {} - this.requestedReviwer = this.eventData?.requested_reviewer || {} - this.name = this.eventData?.action || "" + const data = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')) + this.event = data.eventData + this.pullRequest = data.pullRequest || {} + this.requestedReviwer = data.requestedReviewer || {} + this.name = this.event?.action || "" } catch(err) { - this.eventData = {} + this.event = {} } } } diff --git a/.github/workflows/src/app/airtable.js b/.github/workflows/src/app/airtable.js index b790e63f..de058dba 100644 --- a/.github/workflows/src/app/airtable.js +++ b/.github/workflows/src/app/airtable.js @@ -15,11 +15,11 @@ class ATable { } userParticipated2020(githubLogin) { - return fetchGraduate(githubLogin, GRADUATES_2020) + return this.fetchGraduate(githubLogin, GRADUATES_2020) } fetch2021Graduate(githubLogin) { - return fetchGraduate(githubLogin, GRADUATES_2021) + return this.fetchGraduate(githubLogin, GRADUATES_2021) } fetchGraduate(githubLogin, table) { @@ -36,10 +36,19 @@ class ATable { // This function (`page`) will get called for each page of records. data = records }, function done(err) { - if (err) { console.error(err); return; } + if (err) { + if(err.error === "NOT_FOUND") { + resolve(false) + } + + reject(err) + return; + } }); resolve(data[0]) + }).catch((err)=>{ + reject(err) }) } } diff --git a/.github/workflows/src/app/octokit.js b/.github/workflows/src/app/octokit.js index ea1d3308..b1d39045 100644 --- a/.github/workflows/src/app/octokit.js +++ b/.github/workflows/src/app/octokit.js @@ -8,37 +8,36 @@ class Octo { ` query myQuery($name: String!, $owner: String!, $pr: Int!){ repository(name: $name, owner: $owner) { - pullRequest(number: $pr) { - author { - login - } - bodyText - closed - comments(first: 100) { - edges { - node { - author { - login - } - body - url + pullRequest(number: $pr) { + author { + login + } + bodyText + closed + comments(first: 100) { + edges { + node { + author { + login } + body + url } } + } - files(first: 100) { - edges { - node { - path - additions - deletions - } + files(first: 100) { + edges { + node { + path + additions + deletions } } } } + } } - `, { name: process.env.REPO_NAME, -- knotmirror 0.0.1