From d1bb3286ae4d766cf247153e7b06ebcee9c11bf2 Mon Sep 17 00:00:00 2001 From: Karol Josef F Bustamante Date: Mon, 9 Dec 2024 00:42:37 -0500 Subject: [PATCH] add memoization to getPullRequestComments --- source/platforms/github/GitHubAPI.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/platforms/github/GitHubAPI.ts b/source/platforms/github/GitHubAPI.ts index c19955dcd..e6fc5a700 100644 --- a/source/platforms/github/GitHubAPI.ts +++ b/source/platforms/github/GitHubAPI.ts @@ -10,6 +10,7 @@ import { dangerIDToString } from "../../runner/templates/githubIssueTemplate" import { api as fetch } from "../../api/fetch" import { RepoMetaData } from "../../dsl/RepoMetaData" import { CheckOptions } from "./comms/checks/resultsToCheck" +import memoize from "lodash.memoize" // The Handle the API specific parts of the github @@ -325,13 +326,13 @@ export class GitHubAPI { * @returns {Promise} A promise that resolves to an array of GitHub issue comments. * */ - getPullRequestComments = async (): Promise => { + getPullRequestComments = memoize(async (): Promise => { const pr = await this.getPullRequestInfo() const prNumber = pr.number const repo = this.repoMetadata.repoSlug const owner = pr.base.repo.owner.login return await this.getAllOfResource(`repos/${owner}/${repo}/issues/${prNumber}/comments`) - } + }) getPullRequestInlineComments = async ( dangerID: string