import { Link, useNavigate } from "react-router"; import { SparklesIcon, ClockIcon, ExclamationTriangleIcon, ServerStackIcon, CommandLineIcon, } from "@heroicons/react/24/outline"; const templateQueries = [ { title: "Run duration by workflow", description: "Average execution time and run count per workflow", icon: ClockIcon, sql: "SELECT workflow_name, AVG(duration_seconds) as avg_duration,\n COUNT(*) as run_count\nFROM runs\nGROUP BY workflow_name\nORDER BY avg_duration DESC\nLIMIT 20", }, { title: "Daily failure rate", description: "Failures, totals, and failure percentage by day", icon: ExclamationTriangleIcon, sql: "SELECT date_trunc('day', created_at) as day,\n COUNT(*) FILTER (WHERE status = 'failed') as failures,\n COUNT(*) as total,\n ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'failed') / COUNT(*), 1) as failure_rate\nFROM runs\nGROUP BY 1\nORDER BY 1 DESC\nLIMIT 30", }, { title: "Top repos by activity", description: "Run count and code churn per repository", icon: ServerStackIcon, sql: "SELECT repo, COUNT(*) as runs, SUM(additions) as total_additions,\n SUM(deletions) as total_deletions\nFROM runs\nGROUP BY repo\nORDER BY runs DESC", }, ]; export default function InsightsNew() { const navigate = useNavigate(); return (