gemini-code-assist[bot] commented on code in PR #37663:
URL: https://github.com/apache/beam/pull/37663#discussion_r2842164266


##########
scripts/ci/pr-bot/processPrUpdate.ts:
##########
@@ -64,7 +64,20 @@ async function areReviewersAssigned(
   stateClient: typeof PersistentState
 ): Promise<boolean> {
   const prState = await stateClient.getPrState(pullNumber);
-  return Object.values(prState.reviewersAssignedForLabels).length > 0;
+  if (Object.values(prState.reviewersAssignedForLabels).length > 0) {
+    return true;
+  }
+  const pull = (
+    await getGitHubClient().rest.pulls.get({
+      owner: REPO_OWNER,
+      repo: REPO,
+      pull_number: pullNumber,
+    })
+  ).data;

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The `areReviewersAssigned` function makes an API call to 
`getGitHubClient().rest.pulls.get` to fetch the pull request details. The 
`pull` object is often already available in the calling functions 
(`processPrComment`, `setNextActionReviewers`). Passing the `pull` object as an 
argument to `areReviewersAssigned` would avoid this redundant API call, 
improving efficiency and reducing the risk of rate limiting.
   
   ```typescript
   async function areReviewersAssigned(
     pull: any,
     stateClient: typeof PersistentState
   ): Promise<boolean> {
     const prState = await stateClient.getPrState(pull.number);
     if (Object.values(prState.reviewersAssignedForLabels).length > 0) {
       return true;
     }
     if (pull.requested_reviewers && pull.requested_reviewers.length > 0) {
       return true;
     }
     return false;
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to