Persist umami sql queries and stuff
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- NOTE(simkir): Materialized view called by the crosstab to pivot sim types to cols
|
||||
CREATE MATERIALIZED VIEW weekly_sim_submit_count AS
|
||||
SELECT
|
||||
substring(session.distinct_id SIMILAR '%#"@%#"' ESCAPE '#') AS group,
|
||||
event_data.string_value as sim_type,
|
||||
COUNT(*)
|
||||
FROM
|
||||
website_event
|
||||
JOIN session ON session.session_id = website_event.session_id
|
||||
LEFT OUTER JOIN event_data ON event_data.website_event_id = website_event.event_id
|
||||
WHERE
|
||||
website_event.website_id = '16e7d807-4db5-45fd-92a9-27393445a153'
|
||||
AND website_event.event_type = 2
|
||||
AND website_event.event_name = 'mapster-submit-drifters'
|
||||
AND session.distinct_id IS NOT NULL
|
||||
AND event_data.data_key = 'kind'
|
||||
AND event_data.created_at BETWEEN CURRENT_TIMESTAMP - '7 days'::interval AND CURRENT_TIMESTAMP
|
||||
GROUP BY
|
||||
substring(session.distinct_id SIMILAR '%#"@%#"' ESCAPE '#'),
|
||||
event_data.string_value;
|
||||
Reference in New Issue
Block a user