Compare commits

...

3 Commits

6 changed files with 50 additions and 31 deletions

View File

@ -461,8 +461,8 @@ BEGIN
CASE ISNULL(q.last_source, '')
WHEN 'mrq' THEN 'Similar Quote'
WHEN 'mrs' THEN 'Similar Sale'
WHEN 'dsq' THEN 'Last Sale'
WHEN 'dss' THEN 'Last Quote'
WHEN 'dsq' THEN 'Last Quote'
WHEN 'dss' THEN 'Last Sale'
ELSE ''
END
ELSE 'No Recent'
@ -596,5 +596,5 @@ BEGIN
--------------------------------------------------------------------------------
-- Final: Return all calculated fields and JSON payloads.
--------------------------------------------------------------------------------
SELECT guidance_price, ui_json FROM @queue;
SELECT guidance_price, ui_json FROM @queue;
END;

View File

@ -265,7 +265,7 @@ BEGIN
,_tmath
,_volume_range
FROM
pricequote.target_prices tp
pricequote.target_prices_base tp
WHERE
tp.stlc = _stlc
AND tp.ds = _v1ds
@ -283,7 +283,7 @@ BEGIN
INTO
_tprice_last
FROM
pricequote.target_prices tp
pricequote.target_prices_base tp
WHERE
tp.stlc = _stlc
AND tp.ds = _last_dataseg

View File

@ -14,28 +14,3 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON pricequote.target_prices TO PUBLIC;
DROP TABLE IF EXISTS import.core_target;
CREATE TABLE import.core_target AS (SELECT * FROM pricequote.core_target);
WITH
expand AS (
SELECT
c.compset,
c.stlc,
c.floor,
b.ds,
b.chan,
b.tier,
b.vol,
b.val,
b.price,
json_pretty(to_json(b.math)) math
FROM
pricequote.core_target c
LEFT JOIN LATERAL pricequote.build_pricing_path_base (options||jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')) b ON b.lastflag
)
-- select count(*) from expand
INSERT INTO
pricequote.target_prices_base
SELECT
*
FROM
expand

View File

@ -0,0 +1,27 @@
DELETE FROM pricequote.target_prices_base;
WITH
expand AS (
SELECT
c.compset,
c.stlc,
c.floor,
b.ds,
b.chan,
b.tier,
b.vol,
b.val,
b.price,
b.math math
FROM
pricequote.core_target c
LEFT JOIN LATERAL pricequote.build_pricing_path_base (options||jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')) b ON b.lastflag
)
-- select count(*) from expand
INSERT INTO
pricequote.target_prices_base
SELECT
*
FROM
expand;

View File

@ -0,0 +1,17 @@
DROP TABLE pricequote.target_prices_base CASCADE;
CREATE TABLE pricequote.target_prices_base (
compset TEXT NOT NULL,
stlc TEXT NOT NULL,
floor NUMERIC NOT NULL,
ds TEXT NOT NULL,
chan TEXT NOT NULL,
tier TEXT NOT NULL,
vol INT4RANGE NOT NULL,
val NUMERIC NOT NULL,
price NUMERIC,
math TEXT[],
PRIMARY KEY (stlc, ds, chan, tier, vol)
);
GRANT SELECT, INSERT, UPDATE, DELETE ON pricequote.target_prices_base TO PUBLIC;

View File

@ -8,4 +8,4 @@ SELECT
,price
,to_jsonb(math)::text AS math
FROM
pricequote.target_prices;
pricequote.target_prices_base;