Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

cache review comments #129

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/commenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,13 @@ ${chain}
return top_level_comment
}

private reviewCommentsCache: Record<number, any[]> = {}

async list_review_comments(target: number) {
if (this.reviewCommentsCache[target]) {
return this.reviewCommentsCache[target]
}

const all_comments: any[] = []
let page = 1
try {
Expand All @@ -372,6 +378,7 @@ ${chain}
}
}

this.reviewCommentsCache[target] = all_comments
return all_comments
} catch (e) {
core.warning(`Failed to list review comments: ${e}`)
Expand Down Expand Up @@ -462,7 +469,13 @@ ${chain}
}
}

private issueCommentsCache: Record<number, any[]> = {}

async list_comments(target: number) {
if (this.issueCommentsCache[target]) {
return this.issueCommentsCache[target]
}

const all_comments: any[] = []
let page = 1
try {
Expand All @@ -481,6 +494,7 @@ ${chain}
}
}

this.issueCommentsCache[target] = all_comments
return all_comments
} catch (e: unknown) {
if (e instanceof ChatGPTError) {
Expand Down