\pset pager off
\pset tuples_only on
\pset fieldsep '\t'
SELECT 'grp', id, name, platform, status, subscription_user_concurrency, default_mapped_model FROM groups WHERE id IN (70,75,97) ORDER BY id;
-- account 218 around burst all errors same minute
SELECT 'burst_msg', to_char(date_trunc('minute', created_at AT TIME ZONE 'Asia/Shanghai'), 'YYYY-MM-DD HH24:MI'), count(*), left(coalesce(error_message,''),120), coalesce(upstream_status_code,0), left(coalesce(upstream_errors::text,''),180)
FROM ops_error_logs
WHERE created_at >= TIMESTAMPTZ '2026-05-11 20:30:00+08' AND created_at < TIMESTAMPTZ '2026-05-11 21:20:00+08'
  AND account_id=218
GROUP BY 2,4,5,6 ORDER BY 2,3 DESC;
-- account 218 yesterday all errors summary
SELECT 'acct218_top', count(*), model, request_path, error_message, coalesce(upstream_status_code,0), coalesce(provider_error_code,''), coalesce(network_error_type,'')
FROM ops_error_logs
WHERE created_at >= TIMESTAMPTZ '2026-05-11 00:00:00+08' AND created_at < TIMESTAMPTZ '2026-05-12 00:00:00+08'
  AND account_id=218
GROUP BY 3,4,5,6,7,8 ORDER BY 2 DESC LIMIT 30;
