pearu commented on issue #54696:
URL: https://github.com/apache/arrow/issues/54696#issuecomment-6310519389

   A possible improvement, based on the data above: exempt contributors with a 
few merged pull requests in this repository from the limit. In the period 
above, all 12 closures that hit an author with a previously merged pull request 
would have been avoided with a threshold of 1, and 6 of them with a threshold 
of 3, while all 23 other closures would have been kept. A threshold higher than 
1 makes it harder to get exempted with a single trivial pull request.
   
   The merged count is available with the same search API that the workflow 
already uses for the open count, and is only needed when a contributor is over 
the limit. A sketch with a threshold of 3:
   
   <details>
   <summary>Diff</summary>
   
   ```diff
   diff --git a/.github/workflows/pr_limit/check.js 
b/.github/workflows/pr_limit/check.js
   --- a/.github/workflows/pr_limit/check.js
   +++ b/.github/workflows/pr_limit/check.js
   @@ -62,6 +62,18 @@ async function countOpenPullRequests(github, context, 
username) {
      return data.total_count;
    }
    
   +/**
   + * Returns the number of merged pull requests authored by the user in this
   + * repository.
   + */
   +async function countMergedPullRequests(github, context, username) {
   +  const {data} = await github.rest.search.issuesAndPullRequests({
   +    q: `repo:${context.repo.owner}/${context.repo.repo} is:pr is:merged 
author:${username}`,
   +    per_page: 1
   +  });
   +  return data.total_count;
   +}
   +
    /**
     * Comments on the pull request explaining the limit, then closes it.
     *
   @@ -125,6 +137,13 @@ module.exports = async ({github, context, core}) => {
        return;
      }
    
   +  // Contributors with at least 3 merged pull requests are not limited.
   +  const merged = await countMergedPullRequests(github, context, user.login);
   +  if (merged >= 3) {
   +    core.info(`Skipping: ${user.login} has ${merged} merged pull 
request(s).`);
   +    return;
   +  }
   +
      core.info(`Closing #${pullRequestNumber}: over the limit.`);
      await commentAndClose(github, context, pullRequestNumber, user.login, 
limit, count);
    };
   ```
   
   </details>
   


-- 
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