修正 PChome rescore 重複入隊判斷
This commit is contained in:
@@ -231,20 +231,22 @@ def _ensure_attempt_table(conn) -> None:
|
||||
|
||||
def _already_materialized(conn, *, source: str, sku: str, candidate_id: str) -> bool:
|
||||
row = conn.execute(text("""
|
||||
SELECT 1
|
||||
SELECT attempt_status, COALESCE(best_competitor_product_id, '') AS candidate_id
|
||||
FROM competitor_match_attempts
|
||||
WHERE sku = :sku
|
||||
AND source = :source
|
||||
AND attempt_status = :attempt_status
|
||||
AND COALESCE(best_competitor_product_id, '') = :candidate_id
|
||||
ORDER BY attempted_at DESC, id DESC
|
||||
LIMIT 1
|
||||
"""), {
|
||||
"sku": sku,
|
||||
"source": source,
|
||||
"attempt_status": RESCORE_ACCEPTED_CURRENT_STATUS,
|
||||
"candidate_id": candidate_id,
|
||||
}).first()
|
||||
return row is not None
|
||||
if row is None:
|
||||
return False
|
||||
return (
|
||||
row.attempt_status == RESCORE_ACCEPTED_CURRENT_STATUS
|
||||
and row.candidate_id == candidate_id
|
||||
)
|
||||
|
||||
|
||||
def materialize_rescore_accept_reviews(
|
||||
|
||||
Reference in New Issue
Block a user