Saved queries
The six questions this database is built to answer. Each runs unchanged on SQLite and Postgres.
1. Acceptance criteria with no linked commits or no linked tests2. Commits not tied to any task3. Cycle time4. Requirements changed after the code for one of their criteria merged5. Review turnaround by reviewer6. Full trace for one requirement
5. Review turnaround by reviewer: hours from PR opened to that reviewer's first review.
SQL
-- 5. Review turnaround by reviewer: hours from PR opened to that reviewer's first review.
WITH first_reviews AS (
SELECT reviewer_id, pull_request_id, MIN(submitted_at) AS first_at
FROM reviews
GROUP BY reviewer_id, pull_request_id
)
SELECT p.display_name AS reviewer,
p.source_system,
COUNT(*) AS prs_reviewed,
ROUND(CAST(AVG(((julianday(fr.first_at) - julianday(pr.created_at)) * 24.0)) AS NUMERIC), 1) AS avg_hours,
ROUND(CAST(MIN(((julianday(fr.first_at) - julianday(pr.created_at)) * 24.0)) AS NUMERIC), 1) AS fastest_hours,
ROUND(CAST(MAX(((julianday(fr.first_at) - julianday(pr.created_at)) * 24.0)) AS NUMERIC), 1) AS slowest_hours
FROM first_reviews fr
JOIN pull_requests pr ON pr.id = fr.pull_request_id
JOIN people p ON p.id = fr.reviewer_id
WHERE pr.created_at IS NOT NULL
GROUP BY p.id, p.display_name, p.source_system
ORDER BY avg_hours DESC;
3 rows
| reviewer | source_system | prs_reviewed | avg_hours | fastest_hours | slowest_hours |
|---|---|---|---|---|---|
| Sofia Reyes | synthetic | 30 | 281.3 | 0.1 | 1892.7 |
| Nina Kowalski | synthetic | 32 | 185.9 | 0.7 | 1159.4 |
| Jamal Wright | synthetic | 34 | 164.2 | 0.0 | 2279.7 |