mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-22 07:41:23 -07:00
feat(optimizer): improve process scripts to address stuck issues and stale PRs
This commit is contained in:
@@ -5,3 +5,5 @@ This file documents the metrics tracked by `optimizer1000`.
|
||||
| Metric | Description | Script | Goal |
|
||||
|--------|-------------|--------|------|
|
||||
| open_issues | Number of open issues in the repo | `metrics/scripts/open_issues.js` | Lower is better |
|
||||
| open_community_prs | Number of open community PRs in the repo | `metrics/scripts/open_community_prs.js` | Lower is better |
|
||||
| completed_community_prs | Number of completed community PRs in the repo | `metrics/scripts/completed_community_prs.js` | Greater is better |
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const repoInfo = execSync('gh repo view --json nameWithOwner', { encoding: 'utf-8' });
|
||||
const repo = JSON.parse(repoInfo).nameWithOwner;
|
||||
const [owner, name] = repo.split('/');
|
||||
|
||||
const query = `query($endCursor: String) { repository(owner: "${owner}", name: "${name}") { pullRequests(states: MERGED, first: 100, after: $endCursor) { nodes { authorAssociation } pageInfo { hasNextPage endCursor } } } }`;
|
||||
|
||||
const command = `gh api graphql --paginate -f query='${query}' --jq '.data.repository.pullRequests.nodes[] | select(.authorAssociation != "MEMBER" and .authorAssociation != "OWNER" and .authorAssociation != "COLLABORATOR") | .authorAssociation' | wc -l`;
|
||||
|
||||
const output = execSync(command, { encoding: 'utf-8' });
|
||||
const completedCommunityPrs = parseInt(output.trim(), 10);
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
metric: 'completed_community_prs',
|
||||
value: completedCommunityPrs,
|
||||
timestamp: new Date().toISOString()
|
||||
}));
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const repoInfo = execSync('gh repo view --json nameWithOwner', { encoding: 'utf-8' });
|
||||
const repo = JSON.parse(repoInfo).nameWithOwner;
|
||||
const output = execSync(`gh search prs --state open --repo ${repo} --limit 1000 --json authorAssociation`, { encoding: 'utf-8' });
|
||||
const prs = JSON.parse(output);
|
||||
const communityPrs = prs.filter(pr =>
|
||||
pr.authorAssociation !== 'MEMBER' &&
|
||||
pr.authorAssociation !== 'OWNER' &&
|
||||
pr.authorAssociation !== 'COLLABORATOR'
|
||||
);
|
||||
process.stdout.write(JSON.stringify({
|
||||
metric: 'open_community_prs',
|
||||
value: communityPrs.length,
|
||||
timestamp: new Date().toISOString()
|
||||
}));
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user