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

Commit 4db677f

Browse files
authored
cache review comments (#129)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI Release Notes: - Improvement: Adds caching for review and issue comments in `commenter.ts` to improve performance. > "Caching comments, > Faster response times we see. > Performance improved." <!-- end of auto-generated comment: release notes by openai -->
1 parent 80d0ea7 commit 4db677f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

dist/index.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commenter.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,13 @@ ${chain}
353353
return top_level_comment
354354
}
355355

356+
private reviewCommentsCache: Record<number, any[]> = {}
357+
356358
async list_review_comments(target: number) {
359+
if (this.reviewCommentsCache[target]) {
360+
return this.reviewCommentsCache[target]
361+
}
362+
357363
const all_comments: any[] = []
358364
let page = 1
359365
try {
@@ -372,6 +378,7 @@ ${chain}
372378
}
373379
}
374380

381+
this.reviewCommentsCache[target] = all_comments
375382
return all_comments
376383
} catch (e) {
377384
core.warning(`Failed to list review comments: ${e}`)
@@ -462,7 +469,13 @@ ${chain}
462469
}
463470
}
464471

472+
private issueCommentsCache: Record<number, any[]> = {}
473+
465474
async list_comments(target: number) {
475+
if (this.issueCommentsCache[target]) {
476+
return this.issueCommentsCache[target]
477+
}
478+
466479
const all_comments: any[] = []
467480
let page = 1
468481
try {
@@ -481,6 +494,7 @@ ${chain}
481494
}
482495
}
483496

497+
this.issueCommentsCache[target] = all_comments
484498
return all_comments
485499
} catch (e: unknown) {
486500
if (e instanceof ChatGPTError) {

0 commit comments

Comments
 (0)