fix: prevent repetition of template IDs in template_usage_by_day (#8693)

This commit is contained in:
Marcin Tojek
2023-07-24 15:07:01 +02:00
committed by GitHub
parent f827829afe
commit b7ced94f0f
2 changed files with 18 additions and 8 deletions

View File

@ -1400,11 +1400,16 @@ WITH d AS (
GROUP BY ts.from_, ts.to_, was.user_id
), template_ids AS (
SELECT
template_usage_by_day.from_,
array_agg(template_id) AS ids
FROM (
SELECT DISTINCT
from_,
array_agg(DISTINCT template_id) AS ids
FROM usage_by_day, unnest(template_ids) template_id
unnest(template_ids) AS template_id
FROM usage_by_day
) AS template_usage_by_day
WHERE template_id IS NOT NULL
GROUP BY from_, template_ids
GROUP BY template_usage_by_day.from_
)
SELECT

View File

@ -94,11 +94,16 @@ WITH d AS (
GROUP BY ts.from_, ts.to_, was.user_id
), template_ids AS (
SELECT
template_usage_by_day.from_,
array_agg(template_id) AS ids
FROM (
SELECT DISTINCT
from_,
array_agg(DISTINCT template_id) AS ids
FROM usage_by_day, unnest(template_ids) template_id
unnest(template_ids) AS template_id
FROM usage_by_day
) AS template_usage_by_day
WHERE template_id IS NOT NULL
GROUP BY from_, template_ids
GROUP BY template_usage_by_day.from_
)
SELECT