Files
coder/coderd/database/queries/workspaceagentstats.sql
T

45 lines
809 B
SQL
Raw Normal View History

-- name: InsertWorkspaceAgentStat :one
2022-09-01 14:58:23 -05:00
INSERT INTO
workspace_agent_stats (
2022-09-01 14:58:23 -05:00
id,
created_at,
user_id,
workspace_id,
template_id,
agent_id,
connections_by_proto,
connection_count,
rx_packets,
rx_bytes,
tx_packets,
tx_bytes
2022-09-01 14:58:23 -05:00
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *;
2022-09-01 14:58:23 -05:00
-- name: GetTemplateDAUs :many
2023-01-25 11:30:12 -06:00
SELECT
2022-09-01 14:58:23 -05:00
(created_at at TIME ZONE 'UTC')::date as date,
user_id
FROM
workspace_agent_stats
WHERE
template_id = $1
GROUP BY
date, user_id
ORDER BY
date ASC;
2022-09-01 14:58:23 -05:00
-- name: GetDeploymentDAUs :many
SELECT
(created_at at TIME ZONE 'UTC')::date as date,
user_id
FROM
workspace_agent_stats
GROUP BY
date, user_id
ORDER BY
date ASC;
-- name: DeleteOldWorkspaceAgentStats :exec
DELETE FROM workspace_agent_stats WHERE created_at < NOW() - INTERVAL '30 days';