Skip to content

Commit

Permalink
Add support for external PR review timestamp filtering in getTeamMemb…
Browse files Browse the repository at this point in the history
…erReviews (#323)
  • Loading branch information
bhavyaus authored Nov 21, 2024
1 parent d81cacb commit bf30ae8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion code-review-chat/CodeReviewChat.js

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

8 changes: 8 additions & 0 deletions code-review-chat/CodeReviewChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export async function getTeamMemberReviews(
repo: string,
owner: string,
ghIssue: GitHubIssue | OctoKitIssue,
isExternalPR?: boolean,
) {
const reviews = await octokit.pulls.listReviews({
pull_number: prNumber,
Expand Down Expand Up @@ -401,6 +402,13 @@ export async function getTeamMemberReviews(
if (reviewTimestamp < lastCommitUnixTimestamp) {
continue;
}

// Check that the team member review occurred in the last 24 hours for external PRs
const twentyFourHoursAgo = Date.now() - 24 * 60 * 60 * 1000;
if (isExternalPR && reviewTimestamp < twentyFourHoursAgo) {
continue;
}

const existingReview = latestReviews.get(review.user.login);
if (!existingReview || reviewTimestamp > new Date(existingReview.submitted_at).getTime()) {
latestReviews.set(review.user.login, review);
Expand Down
2 changes: 1 addition & 1 deletion code-review-chat/index.js

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

1 change: 1 addition & 0 deletions code-review-chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class CodeReviewChatAction extends Action {
payload.repository.name,
payload.repository.owner.login,
issue,
true /* isExternalPR */,
);
safeLog(`Found ${teamMemberReviews?.length ?? 0} reviews from team members`);
// Get only the approving reviews from team members
Expand Down

0 comments on commit bf30ae8

Please sign in to comment.