Update umami sql queries

This commit is contained in:
2026-05-26 16:51:46 +02:00
parent f0eb28a627
commit cda142b3d1
4 changed files with 24 additions and 9 deletions
@@ -23,8 +23,8 @@ SELECT
* *
FROM FROM
crosstab( crosstab(
'SELECT "group", sim_type, count::text FROM weekly_sim_submit_count_v2 ORDER BY 1, 2', 'SELECT "group", sim_type, count::text FROM weekly_sim_submit_count WHERE sim_type <> ''lice-network'' AND sim_type <> ''lice-delousing'' ORDER BY 1, 2',
'SELECT DISTINCT sim_type FROM weekly_sim_submit_count_v2 ORDER BY 1' 'SELECT DISTINCT sim_type FROM weekly_sim_submit_count WHERE sim_type <> ''lice-network'' AND sim_type <> ''lice-delousing'' ORDER BY 1'
) AS ct ( ) AS ct (
group_name text, group_name text,
lice bigint, lice bigint,
@@ -33,3 +33,9 @@ FROM
virus bigint, virus bigint,
watercontact bigint watercontact bigint
) )
WHERE
(lice + sedimentation + transport + virus + watercontact) <> 0
AND "group" <> '@oceanbox.io'
ORDER BY
(lice + sedimentation + transport + virus + watercontact) DESC
;
+12 -7
View File
@@ -9,9 +9,11 @@ WITH base AS (
WHERE WHERE
w.website_id = '16e7d807-4db5-45fd-92a9-27393445a153' w.website_id = '16e7d807-4db5-45fd-92a9-27393445a153'
AND w.event_type = 1 AND w.event_type = 1
AND w.created_at BETWEEN '2025-10-13' AND '2025-10-19' -- NOTE: This is only available in grafana
-- AND $__timeFilter(w.created_at)
AND w.created_at BETWEEN current_timestamp - '7 days'::interval and current_timestamp
AND s.distinct_id IS NOT NULL AND s.distinct_id IS NOT NULL
-- AND substring(s.distinct_id SIMILAR '%#"@%#"' ESCAPE '#') IN ('@leroyseafood.com') -- AND substring(s.distinct_id SIMILAR '%#"@%#"' ESCAPE '#') IN ($groups)
), ),
unique_totals AS ( unique_totals AS (
SELECT SELECT
@@ -28,9 +30,12 @@ unique_users AS (
GROUP BY "Group" GROUP BY "Group"
) )
SELECT SELECT
SUM("Users in range") t."Group",
FROM t."Users in range" AS "Weekly users"
unique_totals FROM unique_totals t
LEFT JOIN
unique_users u USING ("Group")
WHERE WHERE
LOWER("Group") NOT IN ('@oceanbox.io') t."Group" <> '@oceanbox.io'
; ORDER BY
"Users in range" DESC;
+4
View File
@@ -14,6 +14,10 @@ WHERE
AND w.event_type = 1 AND w.event_type = 1
AND s.distinct_id IS NOT NULL AND s.distinct_id IS NOT NULL
AND substring(s.distinct_id SIMILAR '%#"@%#"' ESCAPE '#') <> '@oceanbox.io' AND substring(s.distinct_id SIMILAR '%#"@%#"' ESCAPE '#') <> '@oceanbox.io'
AND 2025 < EXTRACT(YEAR FROM w.created_at)
-- NOTE(simkir): We started with umami at this time, so the data that week was not complete
AND (NOT (EXTRACT(YEAR FROM w.created_at) = 2025 AND EXTRACT(WEEK FROM w.created_at) = 37))
AND (NOT (EXTRACT(YEAR FROM w.created_at) = 2025 AND EXTRACT(WEEK FROM w.created_at) = 1))
GROUP BY GROUP BY
week week
ORDER BY ORDER BY