Skip to content

Commit

Permalink
add memoization to getPullRequestComments
Browse files Browse the repository at this point in the history
  • Loading branch information
kfbustam committed Dec 9, 2024
1 parent 0ccee7f commit d1bb328
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -325,13 +326,13 @@ export class GitHubAPI {
* @returns {Promise<GitHubIssueComment[]>} A promise that resolves to an array of GitHub issue comments.
*
*/
getPullRequestComments = async (): Promise<GitHubIssueComment[]> => {
getPullRequestComments = memoize(async (): Promise<GitHubIssueComment[]> => {
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
Expand Down

0 comments on commit d1bb328

Please sign in to comment.