Compare commits
3 Commits
993a476bea
...
c61729e017
Author | SHA1 | Date | |
---|---|---|---|
c61729e017 | |||
ce77ad7de3 | |||
9a410b82d1 |
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
27
tables/rebuild_targets.pg.sql
Normal file
27
tables/rebuild_targets.pg.sql
Normal 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;
|
17
tables/target_prices_base.pg.sql
Normal file
17
tables/target_prices_base.pg.sql
Normal 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;
|
@ -8,4 +8,4 @@ SELECT
|
||||
,price
|
||||
,to_jsonb(math)::text AS math
|
||||
FROM
|
||||
pricequote.target_prices;
|
||||
pricequote.target_prices_base;
|
||||
|
Loading…
Reference in New Issue
Block a user