Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3468000025 |
36
tasks.py
36
tasks.py
@@ -2126,3 +2126,39 @@ def cross_review_prs():
|
||||
continue
|
||||
|
||||
return {"reviews": len(results), "details": results}
|
||||
|
||||
@huey.periodic_task(crontab(hour="0", minute="0"))
|
||||
def metrics_tick():
|
||||
"""Force Multiplier 13: Fleet Cost & Velocity Tracker.
|
||||
|
||||
Calculates daily velocity (issues closed, PRs merged) and logs it to a metrics file.
|
||||
"""
|
||||
gitea = get_gitea_client()
|
||||
repos = ["Timmy_Foundation/timmy-config", "Timmy_Foundation/timmy-home", "Timmy_Foundation/the-nexus"]
|
||||
|
||||
daily_stats = {
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
"issues_closed": 0,
|
||||
"prs_merged": 0,
|
||||
"repo_stats": {}
|
||||
}
|
||||
|
||||
for repo in repos:
|
||||
# Get issues closed in last 24h
|
||||
closed_issues = gitea.get_closed_issues(repo, since="24h")
|
||||
merged_prs = gitea.get_merged_prs(repo, since="24h")
|
||||
|
||||
daily_stats["issues_closed"] += len(closed_issues)
|
||||
daily_stats["prs_merged"] += len(merged_prs)
|
||||
daily_stats["repo_stats"][repo] = {
|
||||
"issues": len(closed_issues),
|
||||
"prs": len(merged_prs)
|
||||
}
|
||||
|
||||
metrics_file = TIMMY_HOME / "logs" / "metrics.jsonl"
|
||||
metrics_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(metrics_file, "a") as f:
|
||||
f.write(json.dumps(daily_stats) + "\n")
|
||||
|
||||
audit_log("metrics_logged", "system", daily_stats, confidence="High")
|
||||
|
||||
Reference in New Issue
Block a user