\pset tuples_only on
\pset format unaligned
select json_build_object(
 'now_shanghai', to_char(now() at time zone 'Asia/Shanghai','YYYY-MM-DD HH24:MI:SS'),
 'today_start_shanghai', to_char(date_trunc('day', now() at time zone 'Asia/Shanghai'),'YYYY-MM-DD HH24:MI:SS'),
 'rows', count(*),
 'min_created_at_shanghai', to_char(min(created_at) at time zone 'Asia/Shanghai','YYYY-MM-DD HH24:MI:SS'),
 'max_created_at_shanghai', to_char(max(created_at) at time zone 'Asia/Shanghai','YYYY-MM-DD HH24:MI:SS')
)::text
from public.request_audit_logs
where created_at >= timezone('Asia/Shanghai', date_trunc('day', now() at time zone 'Asia/Shanghai'));
select path || '|' || source || '|' || coalesce(model,'') || '|' || count(*)
from public.request_audit_logs
where created_at >= timezone('Asia/Shanghai', date_trunc('day', now() at time zone 'Asia/Shanghai'))
group by path, source, model
order by count(*) desc;
