Skip to content

Commit d1bb328

Browse files
committed
add memoization to getPullRequestComments
1 parent 0ccee7f commit d1bb328

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/platforms/github/GitHubAPI.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { dangerIDToString } from "../../runner/templates/githubIssueTemplate"
1010
import { api as fetch } from "../../api/fetch"
1111
import { RepoMetaData } from "../../dsl/RepoMetaData"
1212
import { CheckOptions } from "./comms/checks/resultsToCheck"
13+
import memoize from "lodash.memoize"
1314

1415
// The Handle the API specific parts of the github
1516

@@ -325,13 +326,13 @@ export class GitHubAPI {
325326
* @returns {Promise<GitHubIssueComment[]>} A promise that resolves to an array of GitHub issue comments.
326327
*
327328
*/
328-
getPullRequestComments = async (): Promise<GitHubIssueComment[]> => {
329+
getPullRequestComments = memoize(async (): Promise<GitHubIssueComment[]> => {
329330
const pr = await this.getPullRequestInfo()
330331
const prNumber = pr.number
331332
const repo = this.repoMetadata.repoSlug
332333
const owner = pr.base.repo.owner.login
333334
return await this.getAllOfResource(`repos/${owner}/${repo}/issues/${prNumber}/comments`)
334-
}
335+
})
335336

336337
getPullRequestInlineComments = async (
337338
dangerID: string

0 commit comments

Comments
 (0)