Skip to content

fix: prevent repetition of template IDs in template_usage_by_day #8693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
mtojek committed Jul 24, 2023
commit 540efbde43255920f9da6ae8ff6bb84403460c73
6 changes: 3 additions & 3 deletions coderd/database/queries/insights.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ WITH d AS (
GROUP BY ts.from_, ts.to_, was.user_id
), template_ids AS (
SELECT
from_,
template_usage_by_day.from_,
array_agg(DISTINCT id) AS ids
FROM (
SELECT from_, unnest(ids) AS id
SELECT template_usage_by_day_unnested.from_, unnest(ids) AS id
FROM (
SELECT DISTINCT
from_,
Expand All @@ -107,7 +107,7 @@ WITH d AS (
GROUP BY from_, template_ids
) AS template_usage_by_day_unnested
) AS template_usage_by_day
GROUP BY from_
GROUP BY template_usage_by_day.from_
)

SELECT
Expand Down