Skip to content

Commit 0db240a

Browse files
committed
use 1 minute granularity instead of 5
1 parent cece437 commit 0db240a

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

coderd/database/querier.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/insights.sql

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ GROUP BY workspace_agent_stats.user_id, users.username, users.avatar_url
2222
ORDER BY user_id ASC;
2323

2424
-- name: GetTemplateInsights :one
25-
-- GetTemplateInsights has a granularity of 5 minutes where if a session/app was
26-
-- in use during a minute, we will add 5 minutes to the total usage for that
25+
-- GetTemplateInsights has a granularity of 1 minute where if a session/app was
26+
-- in use during a minute, we will add 1 minute to the total usage for that
2727
-- session/app (per user).
2828
WITH ts AS (
2929
SELECT
3030
d::timestamptz AS from_,
31-
(d::timestamptz + '5 minute'::interval) AS to_,
32-
EXTRACT(epoch FROM '5 minute'::interval) AS seconds
31+
(d::timestamptz + '1 minute'::interval) AS to_,
32+
EXTRACT(epoch FROM '1 minute'::interval) AS seconds
3333
FROM
3434
-- Subtract 1 second from end_time to avoid including the next interval in the results.
35-
generate_series(@start_time::timestamptz, (@end_time::timestamptz) - '1 second'::interval, '5 minute'::interval) d
35+
generate_series(@start_time::timestamptz, (@end_time::timestamptz) - '1 second'::interval, '1 minute'::interval) d
3636
), agent_stats_by_interval_and_user AS (
3737
SELECT
3838
ts.from_,
@@ -79,11 +79,11 @@ FROM agent_stats_by_interval_and_user;
7979
WITH ts AS (
8080
SELECT
8181
d::timestamptz AS from_,
82-
(d::timestamptz + '5 minute'::interval) AS to_,
83-
EXTRACT(epoch FROM '5 minute'::interval) AS seconds
82+
(d::timestamptz + '1 minute'::interval) AS to_,
83+
EXTRACT(epoch FROM '1 minute'::interval) AS seconds
8484
FROM
8585
-- Subtract 1 second from end_time to avoid including the next interval in the results.
86-
generate_series(@start_time::timestamptz, (@end_time::timestamptz) - '1 second'::interval, '5 minute'::interval) d
86+
generate_series(@start_time::timestamptz, (@end_time::timestamptz) - '1 second'::interval, '1 minute'::interval) d
8787
), app_stats_by_user_and_agent AS (
8888
SELECT
8989
ts.from_,

0 commit comments

Comments
 (0)