MCPcopy Create free account
hub / github.com/AztecProtocol/aztec-packages / get_merge_queue_stats

Function get_merge_queue_stats

ci3/ci-metrics/github_data.py:637–666  ·  view source on GitHub ↗

Get merge queue failure rate by day. Triggers backfill if needed.

(date_from: str, date_to: str)

Source from the content-addressed store, hash-verified

635
636
637def get_merge_queue_stats(date_from: str, date_to: str) -> dict:
638 """Get merge queue failure rate by day. Triggers backfill if needed."""
639 # Ensure data is populated (async after first load)
640 import db
641 conn = db.get_db()
642 count = conn.execute('SELECT COUNT(*) as c FROM merge_queue_daily').fetchone()['c']
643 if count == 0:
644 ensure_merge_queue_data() # block on first load
645 else:
646 threading.Thread(target=ensure_merge_queue_data, daemon=True).start()
647
648 rows = db.query(
649 'SELECT date, total, success, failure, cancelled, in_progress '
650 'FROM merge_queue_daily WHERE date >= ? AND date <= ? ORDER BY date',
651 (date_from, date_to))
652
653 total_runs = sum(r['total'] for r in rows)
654 total_fail = sum(r['failure'] for r in rows)
655 total_success = sum(r['success'] for r in rows)
656
657 return {
658 'by_date': rows,
659 'summary': {
660 'total_runs': total_runs,
661 'total_success': total_success,
662 'total_failure': total_fail,
663 'failure_rate': round(total_fail / max(total_runs, 1) * 100, 1),
664 'days': len([r for r in rows if r['total'] > 0]),
665 },
666 }

Callers

nothing calls this directly

Calls 5

ensure_merge_queue_dataFunction · 0.85
executeMethod · 0.65
startMethod · 0.65
queryMethod · 0.65
sumFunction · 0.50

Tested by

no test coverage detected