Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
8ab61b7199 |
@ -25,8 +25,8 @@ export function apply_guidance(doc: any) {
|
|||||||
|
|
||||||
const targetPrice = doc.pricing?.v1tp ?? doc.pricing?.v0tp;
|
const targetPrice = doc.pricing?.v1tp ?? doc.pricing?.v0tp;
|
||||||
const priceBand = doc.pricing?.v1stdv ?? doc.pricing?.v0stdv;
|
const priceBand = doc.pricing?.v1stdv ?? doc.pricing?.v0stdv;
|
||||||
const earlyPrice = doc.hist?.cust?.early_price;
|
const earlyPrice = doc.hist?.cust?.[0]?.early_price;
|
||||||
const earlySeason = doc.hist?.cust?.early_season;
|
const earlySeason = doc.hist?.cust?.[0]?.early_season;
|
||||||
const bridgePremium = doc.pricing?.bridgePremium ?? 1.00000;
|
const bridgePremium = doc.pricing?.bridgePremium ?? 1.00000;
|
||||||
const altHist = doc.hist?.cust?.ds;
|
const altHist = doc.hist?.cust?.ds;
|
||||||
const iidx = doc.pricing?.iidx;
|
const iidx = doc.pricing?.iidx;
|
||||||
|
@ -123,29 +123,24 @@ FROM
|
|||||||
--,flag.source
|
--,flag.source
|
||||||
--,rel.prefer
|
--,rel.prefer
|
||||||
--,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) best
|
--,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) best
|
||||||
jsonb_strip_nulls(
|
flag.source
|
||||||
jsonb_build_object(
|
,jsonb_build_object(
|
||||||
flag.source
|
'relevance' ,relevance
|
||||||
,jsonb_build_object(
|
,'avgunits' ,avgunits
|
||||||
'relevance' ,relevance
|
,'avgordcount' ,avgordcount
|
||||||
,'avgunits' ,avgunits
|
,'avgcustcount' ,avgcustcount
|
||||||
,'avgordcount' ,avgordcount
|
,'avgtargetprice' ,avgtargetprice
|
||||||
,'avgcustcount' ,avgcustcount
|
,'early_season' ,early_season
|
||||||
,'avgtargetprice' ,avgtargetprice
|
,'early_price' ,early_price
|
||||||
,'early_season' ,early_season
|
,'recent_season' ,recent_season
|
||||||
,'early_price' ,early_price
|
,'recent_price' ,recent_price
|
||||||
,'recent_season' ,recent_season
|
,'last_season' ,last_season
|
||||||
,'recent_price' ,recent_price
|
,'last_price' ,last_price
|
||||||
,'last_season' ,last_season
|
,'ds' ,COALESCE(v1ds,v0ds)
|
||||||
,'last_price' ,last_price
|
,'rank' ,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC)
|
||||||
,'ds' ,COALESCE(v1ds,v0ds)
|
,'pricinghistory' ,season
|
||||||
,'rank' ,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC)
|
|
||||||
,'pricinghistory' ,season
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) doc
|
) doc
|
||||||
,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) rnk
|
,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) rnk
|
||||||
,season
|
|
||||||
FROM
|
FROM
|
||||||
flag
|
flag
|
||||||
LEFT OUTER JOIN rel ON
|
LEFT OUTER JOIN rel ON
|
||||||
@ -154,7 +149,8 @@ FROM
|
|||||||
relevance ~ 'vol|exact'
|
relevance ~ 'vol|exact'
|
||||||
)
|
)
|
||||||
--SELECT jsonb_pretty(jsonb_agg(doc)) FROM rel_sort
|
--SELECT jsonb_pretty(jsonb_agg(doc)) FROM rel_sort
|
||||||
SELECT jsonb_obj_aggc(doc) INTO _result FROM rel_sort WHERE rnk = 1;
|
SELECT jsonb_obj_aggc(doc) INTO _result FROM (SELECT jsonb_build_object(source, jsonb_agg(doc ORDER BY doc->>'rank' ASC)) doc FROM rel_sort GROUP BY source) x;
|
||||||
|
--SELECT jsonb_obj_aggc(doc) INTO _result FROM rel_sort WHERE rnk = 1;
|
||||||
|
|
||||||
RETURN _result;
|
RETURN _result;
|
||||||
|
|
||||||
|
@ -117,29 +117,24 @@ FROM
|
|||||||
--,flag.source
|
--,flag.source
|
||||||
--,rel.prefer
|
--,rel.prefer
|
||||||
--,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) best
|
--,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) best
|
||||||
jsonb_strip_nulls(
|
flag.source
|
||||||
jsonb_build_object(
|
,jsonb_build_object(
|
||||||
flag.source
|
'relevance' ,relevance
|
||||||
,jsonb_build_object(
|
,'avgunits' ,avgunits
|
||||||
'relevance' ,relevance
|
,'avgordcount' ,avgordcount
|
||||||
,'avgunits' ,avgunits
|
,'avgcustcount' ,avgcustcount
|
||||||
,'avgordcount' ,avgordcount
|
,'avgtargetprice' ,avgtargetprice
|
||||||
,'avgcustcount' ,avgcustcount
|
,'early_season' ,early_season
|
||||||
,'avgtargetprice' ,avgtargetprice
|
,'early_price' ,early_price
|
||||||
,'early_season' ,early_season
|
,'recent_season' ,recent_season
|
||||||
,'early_price' ,early_price
|
,'recent_price' ,recent_price
|
||||||
,'recent_season' ,recent_season
|
,'last_season' ,last_season
|
||||||
,'recent_price' ,recent_price
|
,'last_price' ,last_price
|
||||||
,'last_season' ,last_season
|
,'ds' ,COALESCE(v1ds,v0ds)
|
||||||
,'last_price' ,last_price
|
,'rank' ,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC)
|
||||||
,'ds' ,COALESCE(v1ds,v0ds)
|
,'pricinghistory' ,season
|
||||||
,'rank' ,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC)
|
|
||||||
,'pricinghistory' ,season
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) doc
|
) doc
|
||||||
,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) rnk
|
,row_number() OVER (PARTITION BY flag.source ORDER BY rel.prefer ASC) rnk
|
||||||
,season
|
|
||||||
FROM
|
FROM
|
||||||
flag
|
flag
|
||||||
LEFT OUTER JOIN rel ON
|
LEFT OUTER JOIN rel ON
|
||||||
@ -150,4 +145,4 @@ FROM
|
|||||||
--SELECT rnk, jsonb_pretty(doc) doc, jsonb_pretty(season) season FROM rel_sort
|
--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_agg(doc)) FROM rel_sort
|
||||||
--SELECT jsonb_pretty(jsonb_obj_aggc(doc)) FROM rel_sort--INTO _result FROM rel_sort WHERE rnk = 1;
|
--SELECT jsonb_pretty(jsonb_obj_aggc(doc)) FROM rel_sort--INTO _result FROM rel_sort WHERE rnk = 1;
|
||||||
SELECT * FROM rel_sort;
|
SELECT jsonb_build_object(source, jsonb_agg(doc ORDER BY doc->>'rank' ASC)) FROM rel_sort GROUP BY source;
|
||||||
|
Loading…
Reference in New Issue
Block a user