Files
gemini-cli/tools/gemini-cli-bot/metrics/scripts/open_issues.ts
T
gemini-cli[bot] 941470670c # Metrics Integrity & Standardized Reporting (BT-01)
This PR addresses the accuracy and standardization of repository metrics, ensuring reliable data for long-term health tracking. It extracts the metrics improvements from PR #26239 while excluding the stale issue policy changes as requested by maintainers.

### 🚀 Improvements

#### 1. Fixed 1000-item Cap
- **GraphQL Integration**: Refactored `open_issues.ts` and `open_prs.ts` to use GraphQL `totalCount`. This bypasses the 1000-item limit of the `gh issue list` and `gh pr list` commands, ensuring accurate reporting of the backlog (currently ~2.4k issues).

#### 2. Standardized CSV Output
- **Format Conversion**: Converted all 8 metric scripts to output **CSV** format (`metric_name,value`) instead of varied JSON formats. This ensures consistency for downstream time-series collection and simplifies ingestion.

#### 3. Accurate Maintainer Activity
- **Association Updates**: Included `COLLABORATOR` in maintainer associations across all scripts (`latency`, `throughput`, `review_distribution`, etc.). This accurately reflects the activity of authorized contributors who may not be direct members of the organization but are core to the development process.

### 🧪 Verification
- Verified GraphQL queries against the GitHub API.
- Confirmed script output format matches the required standard.
- Validated that all 8 scripts execute successfully and produce the expected CSV data.
2026-04-30 00:04:44 +00:00

27 lines
706 B
TypeScript

/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*
* @license
*/
import { execSync } from 'node:child_process';
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
try {
const query = `query { repository(owner: "${GITHUB_OWNER}", name: "${GITHUB_REPO}") { issues(states: OPEN) { totalCount } } }`;
const output = execSync(
`gh api graphql -f query='${query}'`,
{
encoding: 'utf-8',
},
).trim();
const parsed = JSON.parse(output);
const totalCount = parsed?.data?.repository?.issues?.totalCount ?? 0;
console.log(`open_issues,${totalCount}`);
} catch {
// Fallback if gh fails or no issues found
console.log('open_issues,0');
}