Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions tools/gemini-cli-bot/metrics/scripts/open_issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
*/

import { execSync } from 'node:child_process';
import { GITHUB_OWNER, GITHUB_REPO, type MetricOutput } from '../types.js';

try {
const repo = process.env.GITHUB_REPOSITORY || `${GITHUB_OWNER}/${GITHUB_REPO}`;
const count = execSync(
'gh issue list --state open --limit 1000 --json number --jq length',
`gh api "search/issues?q=repo:${repo}+is:issue+is:open" --jq .total_count`,
{
encoding: 'utf-8',
},
).trim();
console.log(`open_issues,${count}`);
} catch {
// Fallback if gh fails or no issues found
console.log('open_issues,0');

const metric: MetricOutput = {
metric: 'open_issues',
value: parseInt(count, 10) || 0,
timestamp: new Date().toISOString(),
};
process.stdout.write(JSON.stringify(metric) + '\n');
} catch (err) {
process.stderr.write(`Error fetching open issues: ${err instanceof Error ? err.message : String(err)}\n`);
const fallback: MetricOutput = {
metric: 'open_issues',
value: 0,
timestamp: new Date().toISOString(),
};
process.stdout.write(JSON.stringify(fallback) + '\n');
}
23 changes: 18 additions & 5 deletions tools/gemini-cli-bot/metrics/scripts/open_prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
*/

import { execSync } from 'node:child_process';
import { GITHUB_OWNER, GITHUB_REPO, type MetricOutput } from '../types.js';

try {
const repo = process.env.GITHUB_REPOSITORY || `${GITHUB_OWNER}/${GITHUB_REPO}`;
const count = execSync(
'gh pr list --state open --limit 1000 --json number --jq length',
`gh api "search/issues?q=repo:${repo}+is:pr+is:open" --jq .total_count`,
{
encoding: 'utf-8',
},
).trim();
console.log(`open_prs,${count}`);
} catch {
// Fallback if gh fails or no PRs found
console.log('open_prs,0');

const metric: MetricOutput = {
metric: 'open_prs',
value: parseInt(count, 10) || 0,
timestamp: new Date().toISOString(),
};
process.stdout.write(JSON.stringify(metric) + '\n');
} catch (err) {
process.stderr.write(`Error fetching open PRs: ${err instanceof Error ? err.message : String(err)}\n`);
const fallback: MetricOutput = {
metric: 'open_prs',
value: 0,
timestamp: new Date().toISOString(),
};
process.stdout.write(JSON.stringify(fallback) + '\n');
}
Loading