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

40 lines
643 B
SQL
Raw Normal View History

2022-09-01 14:58:23 -05:00
-- name: InsertAgentStat :one
INSERT INTO
agent_stats (
id,
created_at,
user_id,
workspace_id,
template_id,
agent_id,
payload
)
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
-- 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
2022-09-01 14:58:23 -05:00
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
agent_stats
GROUP BY
date, user_id
ORDER BY
date ASC;
2022-09-01 14:58:23 -05:00
-- name: DeleteOldAgentStats :exec
DELETE FROM agent_stats WHERE created_at < NOW() - INTERVAL '30 days';