From 10e3a2cb8ad2a91075fc41c5ff64298b09d5c070 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 18 Oct 2023 08:37:38 -0400 Subject: [PATCH] vault backup: 2023-10-18 08:37:38 --- sql/get.sql | 15 +++++++++++++++ sql/price_pool.sql | 14 +++++++------- todo.md | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 sql/get.sql diff --git a/sql/get.sql b/sql/get.sql new file mode 100644 index 0000000..72c6438 --- /dev/null +++ b/sql/get.sql @@ -0,0 +1,15 @@ +SELECT + gset + ,agglevel + ,e.k + ,e.v->>'units' + ,e.v->>'price_usd' + ,e.v->>'target_price' +FROM + rlarp.price_pool_dev + JOIN LATERAL JSONB_EACH(season) e(k,v) ON TRUE +WHERE + gset @> '{"baseitem":"XNS0T1G3"}'::jsonb +ORDER BY + agglevel ASC +; diff --git a/sql/price_pool.sql b/sql/price_pool.sql index d00150a..ba564bf 100644 --- a/sql/price_pool.sql +++ b/sql/price_pool.sql @@ -75,13 +75,13 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS ( SELECT jsonb_strip_nulls( jsonb_build_object( - 'customer' ,CASE WHEN GROUPING(customer ) = 0 THEN customer END - ,'chanwide' ,CASE WHEN GROUPING(chanwide ) = 0 THEN chanwide END - ,'nursery_region' ,CASE WHEN GROUPING(nursery_region ) = 0 THEN nursery_region END - ,'greenhouse_region' ,CASE WHEN GROUPING(greenhouse_region ) = 0 THEN greenhouse_region END - ,'baseitem' ,CASE WHEN GROUPING(baseitem ) = 0 THEN baseitem END - ,'v1dataseg' ,CASE WHEN GROUPING(v1dataseg ) = 0 THEN v1dataseg END - ,'v0dataseg' ,CASE WHEN GROUPING(v0dataseg ) = 0 THEN v0dataseg END + 'cust' ,customer + ,'chan' ,chanwide + ,'nurs' ,nursery_region + ,'ghse' ,greenhouse_region + ,'mold' ,baseitem + ,'v1ds' ,v1dataseg + ,'v0ds' ,v0dataseg ) ) gset ,oseas diff --git a/todo.md b/todo.md index 30f8092..1ffadf0 100644 --- a/todo.md +++ b/todo.md @@ -1,2 +1,4 @@ - [ ] label aggregation levels with a sort and a short label - [ ] unwrap the data to the necessary level to get back to a table +- [ ] what if you want history on an exact SKU to see volume purchases etc? + - maybe just go straight to the data in that case and leave price pool to be the aggregate data