仓库统计
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 工程开发
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 需要 · GitHub
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
import json, pathlib
report = {
"pr": {
"total": total_prs,
"merged": merged_count,
"closed": closed_count,
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor,
},
"issue": {
"total": total_issues,
"bug": bug_count,
"resolved_bugs": resolved_bugs,
}
}
pathlib.Path("/app/report.json").write_text(json.dumps(report, indent=2))
# GitHub Repository Stats via REST API
## Overview
Use the GitHub REST API (no SDK needed) with `curl` + `python3` to pull PR and
issue data for a given repo and date range. The unauthenticated rate limit is 60
requests/hour; set `GITHUB_TOKEN` in the environment for 5000/hour.
## Base URL pattern
```
https://api.github.com/repos/{owner}/{repo}/pulls # PRs
https://api.github.com/repos/{owner}/{repo}/issues # Issues (includes PRs!)
https://api.github.com/search/issues # Search endpoint
```
> Issues endpoint returns both issues AND pull requests. Filter with
> `"pull_request" in item` to separate them.
## Authenticated header (use when token available)
```bash
AUTH_HEADER="-H \"Authorization: token $GITHUB_TOKEN\""
```
## Pagination pattern
GitHub paginates at 100 items max per page. Always loop until an empty page:
```python
import requests, time
def fetch_all(url, params, token=None):
headers = {"Authorization": f"token {token}"} if token else {}
headers["Accept"] = "application/vnd.github+json"
results = []
page = 1
while True:
params["page"] = page
params["per_page"] = 100
r = requests.get(url, headers=headers, params=params)
if r.status_code == 403:
time.sleep(60) # rate-limited, back off
continue
data = r.json()
if not data:
break
results.extend(data)
if len(data) < 100:
break
page += 1
return results
```
## Date filtering
GitHub REST API supports `since` parameter (ISO 8601) for issues/PRs but NOT
`until`. Filter the `until` boundary in Python after fetching:
```python
from datetime import datetime, timezone
def parse_dt(s):
return datetime.fromisoformat(s.replace("Z", "+00:00"))
start = datetime(2024, 12, 1, tzinfo=timezone.utc)
end = datetime(2024, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
created_in_range = [i for i in items
if start <= parse_dt(i["created_at"]) <= end]
```
## Key fields
| Field | Description |
|---|---|
| `number` | PR/issue number |
| `state` | `"open"` or `"closed"` |
| `created_at` | ISO 8601 creation timestamp |
| `closed_at` | ISO 8601 close timestamp (null if open) |
| `merged_at` | ISO 8601 merge timestamp (PRs only, null if unmerged) |
| `pull_request.merged_at` | In issue-endpoint results; same as above |
| `user.login` | Author login |
| `labels` | List of `{"name": "..."}` objects |
## Detecting merged PRs
Via `/pulls` endpoint, `merged_at` is present and non-null.
Via `/issues` endpoint, check `item.get("pull_request", {}).get("merged_at")`.
## Computing average time-to-merge
```python
from datetime import datetime, timezone
def days_between(a, b):
da = datetime.fromisoformat(a.replace("Z", "+00:00"))
db = datetime.fromisoformat(b.replace("Z", "+00:00"))
return (db - da).total_seconds() / 86400
merged = [p for p in prs if p.get("merged_at")]
avg = sum(days_between(p["created_at"], p["merged_at"]) for p in merged) / len(merged)
avg_rounded = round(avg, 1)
```
## Finding top contributor
```python
from collections import Counter
logins = [p["user"]["login"] for p in prs]
top = Counter(logins).most_common(1)[0][0]
```
## Output: write report.json
```python
import json, pathlib
report = {
"pr": {
"total": total_prs,
"merged": merged_count,
"closed": closed_count,
"avg_merge_days": avg_merge_days,
"top_contributor": top_contributor,
},
"issue": {
"total": total_issues,
"bug": bug_count,
"resolved_bugs": resolved_bugs,
}
}
pathlib.Path("/app/report.json").write_text(json.dumps(report, indent=2))
```
---
> Source: [cxcscmu/SkillLearnBench](https://github.com/cxcscmu/SkillLearnBench) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
概述
基本 URL 模式
分页模式
日期过滤
关键领域
文件/命令 -> curl · python3 · GITHUB_TOKEN · "pull_request" in item · since · until · number · state
内容校验值 -> 315549f2ca2c
当前原文的自动摘译,尚未人工审校。
概述
使用 GitHub REST API(无需 SDK)和
curl+python3来提取给定存储库和日期范围内的 PR 和发布数据。未经身份验证的速率限制为 60 个请求/小时;将环境中的GITHUB_TOKEN设置为5000/小时。基本 URL 模式
问题端点返回问题和拉取请求。用
"pull_request" in item过滤将它们分开。分页模式
GitHub 分页,每页最多 100 个项目。始终循环直到出现空页:
日期过滤
GitHub REST API 支持问题/PR 的
since参数 (ISO 8601),但不支持until。获取后在Python中过滤until边界:关键领域
字段 · 描述
number· PR/问题编号state·"open"或"closed"created_at· ISO 8601 创建时间戳closed_at· ISO 8601 关闭时间戳(如果打开则为空)