mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: filter session count sums by created_at (#6529)
Fixes the session totals being waaaaay too high!
This commit is contained in:
@@ -5562,7 +5562,7 @@ WITH agent_stats AS (
|
||||
coalesce(SUM(session_count_reconnecting_pty), 0)::bigint AS session_count_reconnecting_pty
|
||||
FROM (
|
||||
SELECT id, created_at, user_id, agent_id, workspace_id, template_id, connections_by_proto, connection_count, rx_packets, rx_bytes, tx_packets, tx_bytes, connection_median_latency_ms, session_count_vscode, session_count_jetbrains, session_count_reconnecting_pty, session_count_ssh, ROW_NUMBER() OVER(PARTITION BY agent_id ORDER BY created_at DESC) AS rn
|
||||
FROM workspace_agent_stats
|
||||
FROM workspace_agent_stats WHERE created_at > $1
|
||||
) AS a WHERE a.rn = 1
|
||||
)
|
||||
SELECT workspace_rx_bytes, workspace_tx_bytes, workspace_connection_latency_50, workspace_connection_latency_95, session_count_vscode, session_count_ssh, session_count_jetbrains, session_count_reconnecting_pty FROM agent_stats, latest_agent_stats
|
||||
|
||||
@@ -70,7 +70,7 @@ WITH agent_stats AS (
|
||||
coalesce(SUM(session_count_reconnecting_pty), 0)::bigint AS session_count_reconnecting_pty
|
||||
FROM (
|
||||
SELECT *, ROW_NUMBER() OVER(PARTITION BY agent_id ORDER BY created_at DESC) AS rn
|
||||
FROM workspace_agent_stats
|
||||
FROM workspace_agent_stats WHERE created_at > $1
|
||||
) AS a WHERE a.rn = 1
|
||||
)
|
||||
SELECT * FROM agent_stats, latest_agent_stats;
|
||||
|
||||
Reference in New Issue
Block a user