From 11f309941b98598255489db324d39000625593a8 Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Fri, 30 Oct 2020 14:05:15 +0100 Subject: [PATCH] P5-6155 add products datastudio analytics view #140 --- migrations/000.257.sql | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 migrations/000.257.sql diff --git a/migrations/000.257.sql b/migrations/000.257.sql new file mode 100644 index 0000000..e1ce548 --- /dev/null +++ b/migrations/000.257.sql @@ -0,0 +1,32 @@ +-- P5-6180: create datastudio view for contract customer discounts +drop view if exists v_analytics_products; + +create view v_analytics_products as + select + products.productid as product_id, + products.path as product_path, + visible, + browsable, + products.inserted as product_inserted, + products.updated as product_updated, + designers.designerid as designer_id, + designers.name as designer_name, + ref1, + ref2, + ref3, + artno.value as artno, + name.value as product_name, + width.value::int as width, + height.value::int as height, + copyright.value as copyright, + batch.value as batch + from "product-products" products + left join designers on products.designerid = designers.designerid + left join "product-products_fields" artno on artno.fieldid = 1 and artno.productid = products.productid + left join "product-products_fields" name on name.fieldid = 2 and name.productid = products.productid + left join "product-products_fields" width on width.fieldid = 5 and width.productid = products.productid + left join "product-products_fields" height on height.fieldid = 3 and height.productid = products.productid + left join "product-products_fields" copyright on copyright.fieldid = 25 and copyright.productid = products.productid + left join "product-products_fields" batch on batch.fieldid = 36 and batch.productid = products.productid; + +grant select on v_analytics_products to datastudio;