From 32034180f07534735df70c2d0afa4a722976a8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstr=C3=B6m?= Date: Wed, 19 Mar 2025 13:47:35 +0100 Subject: [PATCH] added new funnel for collections (#469) * added new funnel for collections * changed to interger * renamed to correct migration number --- migrations/000.543.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 migrations/000.543.sql diff --git a/migrations/000.543.sql b/migrations/000.543.sql new file mode 100644 index 0000000..9ebfdd0 --- /dev/null +++ b/migrations/000.543.sql @@ -0,0 +1,23 @@ +-- View: public.v_funnel_collections + +DROP VIEW IF EXISTS public.v_funnel_collections; + +CREATE VIEW public.v_funnel_collections AS + SELECT + ep.id as collection_id, + ep.name as collection_name, + jsonb_array_elements_text(metadata->'collection_products')::INTEGER AS product_id, + ep.inserted, + ep.published, + ep.updated, + ep.description + FROM editorial_pages ep + WHERE ep.type = 'collection' + AND EXISTS ( + SELECT 1 + FROM editorial_content ec + WHERE ec.editorial_page_id = ep.id + AND ec.visible = TRUE + ); + +GRANT SELECT ON TABLE public.v_funnel_collections TO funnel;