{
 "notes": "Night 1: establish the baseline Mia and Daniel both asked for first — where volume sits, whether staffing matches it, and the headline SLA miss numbers. I'm starting at the agent-group grain (ties load to staffing and lets us see which queues run slow) and the priority grain (the number Daniel wants for the review, with an 'All' rollup row so we have one true headline rate plus the breakdown). I'm holding macros/KB, root-cause-of-slowness, and CSAT for later nights once I've seen where the pain concentrates — no point drilling into 'why slow' before I know 'where slow'. All three reports use 2025-01-01 to 2025-12-31 (last full year) as the baseline window so later weekly/monthly cuts have something to compare against.",
 "requests": [
  {
   "title": "Ticket volume and staffing by agent group",
   "question": "How is ticket volume distributed across our agent groups, and does staffing (agent count) look balanced against that load?",
   "grain": "one row per agent group (plus one row for tickets with no agent_group_id, labeled 'Unassigned queue')",
   "columns": [
    "agent_group_name",
    "ticket_count (tickets created in 2025)",
    "open_ticket_count (status not in solved, closed, as of 2025-12-31)",
    "agent_count (distinct active support_agents in that group via agent_group_members)",
    "tickets_per_agent (ticket_count / agent_count)",
    "pct_unassigned (share of the group's tickets with assignee_agent_id null)",
    "avg_first_response_minutes (first_response_at - created_at, tickets with a first response)",
    "avg_resolution_minutes (resolved_at - created_at, tickets resolved)"
   ],
   "details": "Window: tickets.created_at between 2025-01-01 and 2025-12-31 inclusive. Source tables: tickets, agent_groups, agent_group_members, support_agents. Join tickets.agent_group_id to agent_groups; count distinct support_agents per group from agent_group_members (count membership, no activity filter). Order by ticket_count descending, with the 'Unassigned queue' row last regardless of count so it reads as a footnote. Round averages to whole minutes and rates to 1 decimal percent.",
   "builds_on": []
  },
  {
   "title": "SLA breach rates by agent group",
   "question": "Which agent groups miss first-response and resolution SLA targets most often, and by how much when they do?",
   "grain": "one row per agent group (plus one row for tickets with no agent_group_id, labeled 'Unassigned queue')",
   "columns": [
    "agent_group_name",
    "ticket_count_with_sla (tickets created in 2025 with a non-null sla_policy_id)",
    "first_response_breach_rate (% of those tickets with a sla_breaches row of breach_kind = first_response)",
    "resolution_breach_rate (% with a sla_breaches row of breach_kind = resolution)",
    "avg_minutes_over_first_response (avg minutes_over for first_response breaches)",
    "avg_minutes_over_resolution (avg minutes_over for resolution breaches)",
    "avg_first_response_minutes (actual first_response_at - created_at)",
    "avg_resolution_minutes (actual resolved_at - created_at)"
   ],
   "details": "Window: tickets.created_at between 2025-01-01 and 2025-12-31 inclusive, restricted to tickets with sla_policy_id not null (tickets actually under an SLA). Source tables: tickets, sla_breaches, agent_groups. Join sla_breaches on ticket_id, split by breach_kind. Order by resolution_breach_rate descending, 'Unassigned queue' row last. Round rates to 1 decimal percent, minutes to whole numbers.",
   "builds_on": []
  },
  {
   "title": "SLA breach rates by priority, with overall headline rate",
   "question": "What is our overall SLA breach rate for 2025, and which priority levels drive the misses?",
   "grain": "one row per ticket priority (low, normal, high, urgent) plus one summary row labeled 'All priorities' totaling across all of them",
   "columns": [
    "priority (or 'All priorities' for the total row)",
    "ticket_count_with_sla",
    "typical_first_response_target_minutes (from sla_policies for that priority, blank on the All row)",
    "typical_resolution_target_minutes (from sla_policies for that priority, blank on the All row)",
    "first_response_breach_rate",
    "resolution_breach_rate",
    "avg_minutes_over_first_response",
    "avg_minutes_over_resolution"
   ],
   "details": "Window: tickets.created_at between 2025-01-01 and 2025-12-31 inclusive, restricted to tickets with sla_policy_id not null. Source tables: tickets, sla_breaches, sla_policies. Compute breach rates per priority as % of that priority's tickets with a matching sla_breaches row (split by breach_kind = first_response / resolution); the 'All priorities' row aggregates across every priority (this is the headline number for the leadership review). Order: 'All priorities' row first, then the four priorities sorted by resolution_breach_rate descending. Round rates to 1 decimal percent, minutes to whole numbers.",
   "builds_on": []
  }
 ]
}