公关统计
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 数据
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# GitHub PR Statistics
## Overview
After fetching PR data from the GitHub API, use Python or jq to compute:
- Total PR count
- Merged vs closed counts
- Average time-to-merge (days)
- Top contributor by PR count
## Fetching PRs for a Date Range
```bash
# Using gh search (handles pagination, date filtering)
gh pr list -R cli/cli \
--search "created:2024-12-01..2024-12-31" \
--state all \
--limit 500 \
--json number,author,createdAt,mergedAt,closedAt,state
```
## Python: Compute Stats from JSON
```python
import json
from datetime import datetime, timezone
from collections import Counter
# Load PR data (from gh pr list --json output)
with open('prs.json') as f:
prs = json.load(f)
total = len(prs)
# Count merged vs closed-but-not-merged
merged = [pr for pr in prs if pr['mergedAt']]
closed = [pr for pr in prs if not pr['mergedAt'] and pr['state'] == 'CLOSED']
# Average time to merge (creation -> mergedAt), in days
def parse_dt(s):
return datetime.fromisoformat(s.replace('Z', '+00:00'))
merge_days = []
for pr in merged:
created = parse_dt(pr['createdAt'])
merged_at = parse_dt(pr['mergedAt'])
delta = (merged_at - created).total_seconds() / 86400
merge_days.append(delta)
avg_merge_days = round(sum(merge_days) / len(merge_days), 1) if merge_days else 0.0
# Top contributor
authors = Counter(pr['author']['login'] for pr in prs)
top_contributor = authors.most_common(1)[0][0]
print(json.dumps({
"total": total,
"merged": len(merged),
"closed": len(closed),
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor
}, indent=2))
```
## Notes on State Values
- `gh pr list --json` returns `state` as `"OPEN"`, `"CLOSED"`, or `"MERGED"`
- `mergedAt` is non-null only for merged PRs
- A PR with `state == "CLOSED"` and `mergedAt == null` is truly closed (not merged)
## Notes on the Search API
- `created:2024-12-01..2024-12-31` is inclusive on both ends
- Dec 31 means up to `2024-12-31T23:59:59Z`
- Use `--limit 500` to avoid truncation for active repos
---
> Source: [cxcscmu/SkillLearnBench](https://github.com/cxcscmu/SkillLearnBench) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
概述
关于状态值的注释
搜索 API 的注释
文件/命令 -> gh pr list --json · state · "OPEN" · "CLOSED" · "MERGED" · mergedAt · state == "CLOSED" · mergedAt == null
内容校验值 -> 8ccfebd8b45d
当前原文的自动摘译,尚未人工审校。
概述
从 GitHub API 获取 PR 数据后,使用 Python 或 jq 计算: 总 PR 计数 合并与关闭计数 平均合并时间(天) 按 PR 计数划分的主要贡献者
关于状态值的注释
gh pr list --json将state返回为"OPEN"、"CLOSED"或"MERGED"mergedAt仅对于合并的 PR 为非空 具有state == "CLOSED"和mergedAt == null的 PR 真正关闭(未合并)搜索 API 的注释
created:2024-12-01..2024-12-31两端均包含 12 月 31 日意味着最多2024-12-31T23:59:59Z使用--limit 500避免活动存储库被截断 来源:cxcscmu/SkillLearnBench — 由 TomeVault 分发。