mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
fix(bot): refactor open_issues and open_prs to use GraphQL
This change refactors the `open_issues.ts` and `open_prs.ts` metric scripts to use the GitHub GraphQL API instead of the `gh` CLI's list commands with hardcoded limits. **Why it is recommended:** The previous implementation used `gh issue list --limit 1000`, which caused the metrics to cap at 1000 items. As the repository now has approximately 2400 open issues, the metrics were reporting inaccurate data, hiding the true scale of the backlog and potentially misleading repository health analysis. **Expected metric improvement:** The `open_issues` and `open_prs` metrics will now report accurate total counts, regardless of the 1000-item CLI limit. This will result in an immediate correction of the `open_issues` metric from 1000 to approximately 2400. **Productivity Impact:** Accurate metrics enable better data-backed decisions regarding maintainer workload and triage prioritization.
This commit is contained in:
@@ -4,16 +4,25 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const count = execSync(
|
||||
'gh pr list --state open --limit 1000 --json number --jq length',
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
).trim();
|
||||
console.log(`open_prs,${count}`);
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(states: OPEN) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(
|
||||
`gh api graphql -F owner=${GITHUB_OWNER} -F repo=${GITHUB_REPO} -f query='${query}'`,
|
||||
{ encoding: 'utf-8' },
|
||||
);
|
||||
const data = JSON.parse(output).data.repository;
|
||||
console.log(`open_prs,${data.pullRequests.totalCount}`);
|
||||
} catch {
|
||||
// Fallback if gh fails or no PRs found
|
||||
console.log('open_prs,0');
|
||||
|
||||
Reference in New Issue
Block a user