put target rebuild in a proc

This commit is contained in:
Paul Trowbridge 2025-09-08 08:50:28 -04:00
parent 581224dad8
commit 5ec3f1d9c1

View File

@ -1,9 +1,11 @@
BEGIN; CREATE OR REPLACE PROCEDURE pricequote.refresh_target_prices_base()
DELETE FROM pricequote.target_prices_base; LANGUAGE plpgsql
AS $$
BEGIN
DELETE FROM pricequote.target_prices_base;
WITH WITH expand AS (
expand AS ( SELECT
SELECT
c.compset, c.compset,
c.stlc, c.stlc,
c.floor, c.floor,
@ -13,17 +15,14 @@ SELECT
b.vol, b.vol,
b.val, b.val,
b.price, b.price,
b.math math b.math AS math
FROM FROM pricequote.core_target c
pricequote.core_target c LEFT JOIN LATERAL pricequote.build_pricing_path_base(
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 c.options || jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')
) ) AS b
-- select count(*) from expand ON b.lastflag
INSERT INTO )
pricequote.target_prices_base INSERT INTO pricequote.target_prices_base
SELECT SELECT * FROM expand;
* END;
FROM $$;
expand;
COMMIT;