liuhao1024
9e2f07e704
perf(dashboard): use GROUP BY for session stats instead of fetching 10k rows
...
Replaces the O(N) list_sessions_rich histogram in /api/sessions/stats
with a single GROUP BY query, reducing response time from ~575ms to
<1ms on large databases.
Original PR #48921 by @liuhao1024. Salvage fixes based on review
feedback from teknium1 and @wernerhp:
1. Preserve try/except guard — a DB error still degrades to empty
by_source instead of failing the whole stats response.
2. GROUP BY COALESCE(source, 'cli') — the original GROUP BY source
could emit duplicate 'cli' keys (NULL group + literal 'cli' group)
that the dict comprehension silently dropped.
3. Add exclude_children=True — list_sessions_rich excludes subagent
runs, delegates, and compression continuations by default; the
bare GROUP BY counted all rows, inflating source counts.
Aggregate shape (exclude_children/include_archived/limit params)
adapted from closed duplicate #61120 by @mijanx.
Closes #48914
Co-authored-by: mijanx <mijanx@users.noreply.github.com >
2026-07-28 19:07:28 +05:30
..
2026-07-24 19:43:44 -05:00
2026-07-22 16:51:01 -04:00
2026-07-27 22:28:08 -04:00
2026-07-20 11:35:21 -07:00
2026-07-24 15:53:38 -07:00
2026-07-26 12:54:45 -07:00
2026-07-23 18:20:24 -07:00
2026-06-24 00:54:18 +05:30
2026-07-26 17:47:07 -07:00
2026-07-26 21:13:03 -07:00
2026-07-26 17:49:03 -07:00
2026-07-17 11:37:25 +05:30
2026-07-26 21:22:40 -07:00
2026-07-11 12:28:55 +05:30
2026-07-25 21:44:43 -07:00
2026-07-24 17:10:39 -07:00
2026-07-18 02:49:28 -07:00
2026-07-26 17:46:55 -07:00
2026-07-24 16:01:06 -07:00
2026-07-24 11:45:57 -07:00
2026-07-28 03:54:25 -05:00
2026-07-22 08:11:09 +05:30
2026-07-26 21:13:03 -07:00
2026-07-24 11:45:57 -07:00
2026-07-21 05:27:13 -07:00
2026-07-01 23:51:54 +05:30
2026-07-26 21:13:03 -07:00
2026-07-28 17:52:21 +05:30
2026-07-22 16:51:01 -04:00
2026-07-24 17:10:39 -07:00
2026-07-22 21:17:21 -07:00
2026-07-24 11:45:57 -07:00
2026-07-19 03:02:21 -07:00
2026-07-24 15:52:13 -07:00
2026-07-25 19:27:17 -07:00
2026-07-26 21:22:40 -07:00
2026-06-27 21:30:37 -07:00
2026-07-05 13:42:46 -07:00
2026-06-24 18:56:26 -07:00
2026-06-27 20:45:31 -07:00
2026-06-30 17:29:23 -07:00
2026-07-07 04:09:35 -07:00
2026-07-27 14:32:05 -07:00
2026-07-28 00:15:00 +05:00
2026-07-24 16:02:08 -07:00
2026-07-26 23:41:54 -07:00
2026-07-16 07:19:36 -07:00
2026-07-26 18:10:34 -07:00
2026-07-08 16:55:32 +10:00
2026-07-26 17:50:54 -07:00
2026-07-26 08:43:24 -07:00
2026-07-20 05:38:25 -07:00
2026-07-27 22:28:08 -04:00
2026-07-26 17:46:29 -07:00
2026-07-15 07:39:42 -07:00
2026-07-28 03:52:33 -05:00
2026-07-01 16:25:48 -05:00
2026-07-27 22:28:08 -04:00
2026-07-15 07:39:17 -07:00
2026-07-09 16:13:59 -05:00
2026-07-15 07:39:17 -07:00
2026-06-21 17:06:48 -07:00
2026-07-26 13:42:33 -07:00
2026-07-05 13:42:46 -07:00
2026-07-27 11:33:40 -07:00
2026-06-19 07:46:33 -07:00
2026-07-26 17:20:27 -07:00
2026-07-15 04:56:25 -07:00
2026-07-28 00:53:16 -05:00
2026-06-21 19:05:27 -07:00
2026-07-26 14:14:03 -07:00
2026-06-22 19:16:47 -05:00
2026-07-26 19:29:18 -07:00
2026-07-27 22:28:08 -04:00
2026-07-23 18:11:57 -07:00
2026-07-23 21:07:18 -07:00
2026-07-15 00:10:31 -07:00
2026-07-27 19:32:12 +05:30
2026-07-26 21:22:40 -07:00
2026-07-24 21:12:53 -05:00
2026-07-27 11:53:48 -04:00
2026-07-26 21:22:40 -07:00
2026-06-21 22:43:48 -07:00
2026-07-21 12:20:25 +05:30
2026-06-24 00:14:49 -07:00
2026-07-24 11:45:57 -07:00
2026-07-26 17:46:55 -07:00
2026-07-02 05:10:31 -07:00
2026-06-24 13:48:38 -05:00
2026-07-27 11:33:40 -07:00
2026-07-27 22:28:08 -04:00
2026-07-05 13:42:46 -07:00
2026-07-15 07:39:17 -07:00
2026-06-27 15:59:00 -07:00
2026-07-24 17:10:39 -07:00
2026-06-25 16:40:26 -05:00
2026-07-21 10:09:31 -04:00
2026-07-26 18:06:21 -07:00
2026-06-25 13:52:06 -07:00
2026-07-27 11:53:48 -04:00
2026-07-24 09:49:00 -07:00
2026-07-07 15:15:37 -07:00
2026-06-27 15:59:00 -07:00
2026-07-22 11:19:37 +05:30
2026-07-27 11:53:48 -04:00
2026-06-17 01:04:26 +08:00
2026-07-24 11:45:57 -07:00
2026-06-21 19:05:27 -07:00
2026-06-19 07:46:33 -07:00
2026-07-27 19:19:01 +05:30
2026-07-09 19:54:02 -07:00
2026-07-07 12:36:41 -07:00
2026-07-07 13:29:58 -07:00
2026-07-26 19:30:21 -07:00
2026-07-03 13:44:00 -07:00
2026-07-17 04:53:38 -07:00
2026-07-26 23:34:29 -07:00
2026-07-26 08:43:24 -07:00
2026-07-27 22:28:08 -04:00
2026-07-09 19:57:54 -07:00
2026-07-26 19:29:56 -07:00
2026-07-21 21:00:43 -05:00
2026-07-21 21:00:43 -05:00
2026-07-23 12:01:24 -07:00
2026-07-24 16:00:03 -07:00
2026-07-25 23:05:30 -07:00
2026-06-25 16:40:26 -05:00
2026-07-28 00:15:00 +05:00
2026-07-05 13:42:46 -07:00
2026-07-26 12:54:45 -07:00
2026-07-26 16:01:54 -07:00
2026-06-26 14:07:43 +05:30
2026-07-24 17:10:39 -07:00
2026-07-11 12:28:55 +05:30
2026-07-27 21:26:23 -07:00
2026-07-24 11:45:57 -07:00
2026-07-28 19:07:28 +05:30
2026-07-24 11:45:57 -07:00
2026-07-24 11:45:57 -07:00
2026-07-05 23:00:34 +05:30