From b04f67d9f07aa0ba5caa4ac3f7679e2ec8050001 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 21 Nov 2023 15:38:47 -0500 Subject: [PATCH] variables are nested in customer json --- sql/get_guidance_dseg.pg.sql | 3 ++- sql/get_hist_debug.pg.sql | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sql/get_guidance_dseg.pg.sql b/sql/get_guidance_dseg.pg.sql index 019b3d9..98891fe 100644 --- a/sql/get_guidance_dseg.pg.sql +++ b/sql/get_guidance_dseg.pg.sql @@ -156,7 +156,8 @@ BEGIN --RAISE NOTICE 'cust %', jsonb_pretty(_customer); ----------------price history------------------------------- - SELECT jsonb_build_object('hist',rlarp.get_hist(_mold, _v1ds, _cust, substring(_chan,1,1))) INTO _hist; + RAISE NOTICE 'varb %', _customer; + SELECT jsonb_build_object('hist',rlarp.get_hist(_mold, _v1ds, _customer->'customer'->>'cust', substring(_customer->'customer'->>'chan',1,1))) INTO _hist; --RAISE NOTICE 'history %', jsonb_pretty(_hist); ----------------target pricing------------------------------ diff --git a/sql/get_hist_debug.pg.sql b/sql/get_hist_debug.pg.sql index e7295cf..2f76851 100644 --- a/sql/get_hist_debug.pg.sql +++ b/sql/get_hist_debug.pg.sql @@ -1,5 +1,5 @@ WITH -sel AS (select 'v1:P.P.PLT..' _v1ds, 'ALTMAN PLANTS' _cust, 'XNS0T1G3' _mold, 'D' _chan) +sel AS (select 'v1:L..PLT..' _v1ds, 'DREAM WITH COLORS' _cust, 'UL.12000' _mold, 'D' _chan) ,sort AS ( SELECT p.agglevel @@ -150,4 +150,5 @@ FROM --SELECT rnk, jsonb_pretty(doc) doc, jsonb_pretty(season) season FROM rel_sort --SELECT jsonb_pretty(jsonb_agg(doc)) FROM rel_sort --SELECT jsonb_pretty(jsonb_obj_aggc(doc)) FROM rel_sort--INTO _result FROM rel_sort WHERE rnk = 1; -SELECT * FROM rel_sort; +--SELECT * FROM rel_sort; +SELECT jsonb_obj_aggc(doc) FROM rel_sort WHERE rnk = 1;