mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix: prevent repetition of template IDs in template_usage_by_day
(#8693)
This commit is contained in:
@ -1400,11 +1400,16 @@ WITH d AS (
|
|||||||
GROUP BY ts.from_, ts.to_, was.user_id
|
GROUP BY ts.from_, ts.to_, was.user_id
|
||||||
), template_ids AS (
|
), template_ids AS (
|
||||||
SELECT
|
SELECT
|
||||||
from_,
|
template_usage_by_day.from_,
|
||||||
array_agg(DISTINCT template_id) AS ids
|
array_agg(template_id) AS ids
|
||||||
FROM usage_by_day, unnest(template_ids) template_id
|
FROM (
|
||||||
|
SELECT DISTINCT
|
||||||
|
from_,
|
||||||
|
unnest(template_ids) AS template_id
|
||||||
|
FROM usage_by_day
|
||||||
|
) AS template_usage_by_day
|
||||||
WHERE template_id IS NOT NULL
|
WHERE template_id IS NOT NULL
|
||||||
GROUP BY from_, template_ids
|
GROUP BY template_usage_by_day.from_
|
||||||
)
|
)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -94,11 +94,16 @@ WITH d AS (
|
|||||||
GROUP BY ts.from_, ts.to_, was.user_id
|
GROUP BY ts.from_, ts.to_, was.user_id
|
||||||
), template_ids AS (
|
), template_ids AS (
|
||||||
SELECT
|
SELECT
|
||||||
from_,
|
template_usage_by_day.from_,
|
||||||
array_agg(DISTINCT template_id) AS ids
|
array_agg(template_id) AS ids
|
||||||
FROM usage_by_day, unnest(template_ids) template_id
|
FROM (
|
||||||
|
SELECT DISTINCT
|
||||||
|
from_,
|
||||||
|
unnest(template_ids) AS template_id
|
||||||
|
FROM usage_by_day
|
||||||
|
) AS template_usage_by_day
|
||||||
WHERE template_id IS NOT NULL
|
WHERE template_id IS NOT NULL
|
||||||
GROUP BY from_, template_ids
|
GROUP BY template_usage_by_day.from_
|
||||||
)
|
)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
Reference in New Issue
Block a user