V10.546 補近門檻舊候選回刷
This commit is contained in:
@@ -1159,14 +1159,49 @@ class CompetitorPriceFeeder:
|
||||
WHERE cma.source = 'pchome'
|
||||
ORDER BY cma.sku, cma.attempted_at DESC, cma.id DESC
|
||||
),
|
||||
legacy_unmasked_attempt AS (
|
||||
SELECT DISTINCT ON (cma.sku, cma.best_competitor_product_id)
|
||||
cma.sku,
|
||||
cma.best_competitor_product_id,
|
||||
cma.best_competitor_product_name,
|
||||
cma.best_match_score,
|
||||
cma.attempt_status,
|
||||
cma.hard_veto,
|
||||
cma.match_diagnostic_json,
|
||||
cma.attempted_at
|
||||
FROM competitor_match_attempts cma
|
||||
JOIN latest_attempt current_la
|
||||
ON current_la.sku = cma.sku
|
||||
WHERE cma.source = 'pchome'
|
||||
AND current_la.attempt_status IN (
|
||||
'refresh_no_result',
|
||||
'no_result',
|
||||
'expired_match'
|
||||
)
|
||||
AND cma.attempt_status IN (
|
||||
'low_score',
|
||||
'refresh_low_score',
|
||||
'recoverable_low_score',
|
||||
'true_low_confidence',
|
||||
'rescore_accepted_current'
|
||||
)
|
||||
AND cma.attempted_at < current_la.attempted_at
|
||||
ORDER BY cma.sku, cma.best_competitor_product_id, cma.attempted_at DESC, cma.id DESC
|
||||
),
|
||||
candidate_attempt AS (
|
||||
SELECT la.*
|
||||
FROM latest_attempt la
|
||||
SELECT DISTINCT ON (la.sku, la.best_competitor_product_id)
|
||||
la.*
|
||||
FROM (
|
||||
SELECT * FROM latest_attempt
|
||||
UNION ALL
|
||||
SELECT * FROM legacy_unmasked_attempt
|
||||
) la
|
||||
WHERE la.best_competitor_product_id IS NOT NULL
|
||||
AND la.best_competitor_product_id <> ''
|
||||
AND COALESCE(la.best_match_score, 0) >= :min_score
|
||||
AND COALESCE(la.hard_veto, false) = false
|
||||
AND COALESCE(la.match_diagnostic_json->>'comparison_mode', 'exact_identity') = 'exact_identity'
|
||||
ORDER BY la.sku, la.best_competitor_product_id, la.attempted_at DESC
|
||||
)
|
||||
SELECT
|
||||
p.id AS product_id,
|
||||
|
||||
Reference in New Issue
Block a user