P5-6155 add products datastudio analytics view #140

This commit is contained in:
Martin Carlsson
2020-10-30 14:05:15 +01:00
committed by GitHub
parent af169d626d
commit 11f309941b
+32
View File
@@ -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;