vault backup: 2023-11-10 02:04:16

This commit is contained in:
Paul Trowbridge 2023-11-10 02:04:16 -05:00
parent 4c79a1ec5f
commit aa5f2a0a51
2 changed files with 8 additions and 5 deletions

View File

@ -10,6 +10,7 @@ DECLARE
--_ship text;
--_qty numeric;
--_seas int;
_prem jsonb;
_mold text;
_item text;
_cust text;
@ -148,8 +149,8 @@ BEGIN
--RAISE NOTICE 'list: %', jsonb_pretty(_list);
----------------get premium for quote hist gap--------------
--SELECT coalesce(rlarp.get_premium(_stlc, _seas, (SELECT xchan FROM _chx WHERE chan = _chan),_v1ds, ((_rslt->'mostRelevantCustomerPriceInfo')->'source')->>'v1ds'),'{}'::jsonb) INTO _prem;
--_rslt := _rslt||_prem;
SELECT coalesce(rlarp.get_premium(_stlc, _seas, (SELECT xchan FROM _chx WHERE chan = _chan),_rslt->'hist'->'cust'->>'ds', _v1ds),'{}'::jsonb) INTO _prem;
_rslt := _rslt||_prem;
--RAISE NOTICE 'list: %', jsonb_pretty(_list);
RETURN _rslt;

View File

@ -119,9 +119,10 @@ FROM
--,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) best
jsonb_strip_nulls(
jsonb_build_object(
relevance
flag.source
,jsonb_build_object(
'avgunits' ,avgunits
'relevance' ,relevance
,'avgunits' ,avgunits
,'avgordcount' ,avgordcount
,'avgcustcount' ,avgcustcount
,'avgtargetprice' ,avgtargetprice
@ -135,6 +136,7 @@ FROM
)
)
) doc
,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) rnk
FROM
flag
LEFT OUTER JOIN rel ON
@ -143,7 +145,7 @@ FROM
relevance ~ 'vol|exact'
)
--SELECT jsonb_pretty(jsonb_agg(doc)) FROM rel_sort
SELECT jsonb_obj_aggc(doc) INTO _result FROM rel_sort;
SELECT jsonb_obj_aggc(doc) INTO _result FROM rel_sort WHERE rnk = 1;
RETURN _result;