mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat(coderd/database): add template_usage_stats
table and rollup query (#12664)
Add `template_usage_stats` table for aggregating tempalte usage data. Data is rolled up by the `UpsertTemplateUsageStats` query, which fetches data from the `workspace_agent_stats` and `workspace_app_stats` tables.
This commit is contained in:
committed by
GitHub
parent
a6b8f381f0
commit
04f0510b09
30
coderd/database/migrations/testdata/fixtures/000203_template_usage_stats.up.sql
vendored
Normal file
30
coderd/database/migrations/testdata/fixtures/000203_template_usage_stats.up.sql
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
INSERT INTO
|
||||
template_usage_stats (
|
||||
start_time,
|
||||
end_time,
|
||||
template_id,
|
||||
user_id,
|
||||
median_latency_ms,
|
||||
usage_mins,
|
||||
ssh_mins,
|
||||
sftp_mins,
|
||||
reconnecting_pty_mins,
|
||||
vscode_mins,
|
||||
jetbrains_mins,
|
||||
app_usage_mins
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
date_trunc('hour', NOW()),
|
||||
date_trunc('hour', NOW()) + '30 minute'::interval,
|
||||
gen_random_uuid(),
|
||||
gen_random_uuid(),
|
||||
45.342::real,
|
||||
30, -- usage
|
||||
30, -- ssh
|
||||
5, -- sftp
|
||||
2, -- reconnecting_pty
|
||||
10, -- vscode
|
||||
10, -- jetbrains
|
||||
'{"[terminal]": 2, "code-server": 30}'::jsonb
|
||||
);
|
Reference in New Issue
Block a user