diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index 0b2c1d9a6822a..913d3a040e8b8 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -3256,7 +3256,7 @@ WITH AND date_trunc('minute', was.created_at) = mb.minute_bucket AND was.template_id = mb.template_id AND was.user_id = mb.user_id - AND was.connection_median_latency_ms >= 0 + AND was.connection_median_latency_ms > 0 GROUP BY mb.start_time, mb.template_id, mb.user_id ) @@ -12423,8 +12423,9 @@ WITH agent_stats AS ( coalesce((PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_50, coalesce((PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_95 FROM workspace_agent_stats - -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. - WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 GROUP BY user_id, agent_id, workspace_id, template_id + -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. + WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 + GROUP BY user_id, agent_id, workspace_id, template_id ), latest_agent_stats AS ( SELECT a.agent_id, @@ -12729,9 +12730,11 @@ WITH agent_stats AS ( agent_id, workspace_id, coalesce(SUM(rx_bytes), 0)::bigint AS rx_bytes, - coalesce(SUM(tx_bytes), 0)::bigint AS tx_bytes + coalesce(SUM(tx_bytes), 0)::bigint AS tx_bytes, + coalesce(MAX(connection_median_latency_ms), 0)::float AS connection_median_latency_ms FROM workspace_agent_stats - WHERE workspace_agent_stats.created_at > $1 + -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. + WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 GROUP BY user_id, agent_id, workspace_id ), latest_agent_stats AS ( SELECT @@ -12746,12 +12749,6 @@ WITH agent_stats AS ( -- spread across multiple rows. WHERE usage = true AND created_at > now() - '1 minute'::interval GROUP BY user_id, agent_id, workspace_id -), latest_agent_latencies AS ( - SELECT - agent_id, - coalesce(MAX(connection_median_latency_ms), 0)::float AS connection_median_latency_ms - FROM workspace_agent_stats - GROUP BY user_id, agent_id, workspace_id ) SELECT users.username, workspace_agents.name AS agent_name, workspaces.name AS workspace_name, rx_bytes, tx_bytes, @@ -12767,10 +12764,6 @@ LEFT JOIN latest_agent_stats ON agent_stats.agent_id = latest_agent_stats.agent_id -JOIN - latest_agent_latencies -ON - agent_stats.agent_id = latest_agent_latencies.agent_id JOIN users ON diff --git a/coderd/database/queries/insights.sql b/coderd/database/queries/insights.sql index 79b0d43529e4b..de107bc0e80c7 100644 --- a/coderd/database/queries/insights.sql +++ b/coderd/database/queries/insights.sql @@ -661,7 +661,7 @@ WITH AND date_trunc('minute', was.created_at) = mb.minute_bucket AND was.template_id = mb.template_id AND was.user_id = mb.user_id - AND was.connection_median_latency_ms >= 0 + AND was.connection_median_latency_ms > 0 GROUP BY mb.start_time, mb.template_id, mb.user_id ) diff --git a/coderd/database/queries/workspaceagentstats.sql b/coderd/database/queries/workspaceagentstats.sql index 037458528f206..f2f2bdbe2824e 100644 --- a/coderd/database/queries/workspaceagentstats.sql +++ b/coderd/database/queries/workspaceagentstats.sql @@ -188,8 +188,9 @@ WITH agent_stats AS ( coalesce((PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_50, coalesce((PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_95 FROM workspace_agent_stats - -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. - WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 GROUP BY user_id, agent_id, workspace_id, template_id + -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. + WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 + GROUP BY user_id, agent_id, workspace_id, template_id ), latest_agent_stats AS ( SELECT a.agent_id, @@ -332,9 +333,11 @@ WITH agent_stats AS ( agent_id, workspace_id, coalesce(SUM(rx_bytes), 0)::bigint AS rx_bytes, - coalesce(SUM(tx_bytes), 0)::bigint AS tx_bytes + coalesce(SUM(tx_bytes), 0)::bigint AS tx_bytes, + coalesce(MAX(connection_median_latency_ms), 0)::float AS connection_median_latency_ms FROM workspace_agent_stats - WHERE workspace_agent_stats.created_at > $1 + -- The greater than 0 is to support legacy agents that don't report connection_median_latency_ms. + WHERE workspace_agent_stats.created_at > $1 AND connection_median_latency_ms > 0 GROUP BY user_id, agent_id, workspace_id ), latest_agent_stats AS ( SELECT @@ -349,12 +352,6 @@ WITH agent_stats AS ( -- spread across multiple rows. WHERE usage = true AND created_at > now() - '1 minute'::interval GROUP BY user_id, agent_id, workspace_id -), latest_agent_latencies AS ( - SELECT - agent_id, - coalesce(MAX(connection_median_latency_ms), 0)::float AS connection_median_latency_ms - FROM workspace_agent_stats - GROUP BY user_id, agent_id, workspace_id ) SELECT users.username, workspace_agents.name AS agent_name, workspaces.name AS workspace_name, rx_bytes, tx_bytes, @@ -370,10 +367,6 @@ LEFT JOIN latest_agent_stats ON agent_stats.agent_id = latest_agent_stats.agent_id -JOIN - latest_agent_latencies -ON - agent_stats.agent_id = latest_agent_latencies.agent_id JOIN users ON
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: