diff --git a/config.py b/config.py index 4af757d..2f2f4ed 100644 --- a/config.py +++ b/config.py @@ -320,7 +320,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.335" +SYSTEM_VERSION = "V10.336" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/services/competitor_price_feeder.py b/services/competitor_price_feeder.py index 0f8412a..646dac9 100644 --- a/services/competitor_price_feeder.py +++ b/services/competitor_price_feeder.py @@ -679,6 +679,7 @@ class CompetitorPriceFeeder: 這條路徑不重新搜尋,只用前次留下的 PChome product_id 批次查詢最新商品資料, 適合把舊 scorer 卡在 0.70~0.759 的真同款重新推進正式比價。 + 已重評後仍不足門檻的 refresh_low_score 不再重複進隊列,避免排程空轉。 """ if self.engine is None: raise RuntimeError("需要注入 SQLAlchemy engine") @@ -733,7 +734,7 @@ class CompetitorPriceFeeder: AND COALESCE(cp.tags, '[]'::jsonb) ? 'identity_v2' WHERE lm.rn = 1 AND cp.sku IS NULL - AND la.attempt_status IN ('low_score', 'refresh_low_score') + AND la.attempt_status = 'low_score' AND COALESCE(la.best_match_score, 0) >= :min_score AND COALESCE(la.hard_veto, false) = false ORDER BY la.best_match_score DESC NULLS LAST, lm.momo_price DESC NULLS LAST, lm.sku diff --git a/tests/test_competitor_match_attempts_persistence.py b/tests/test_competitor_match_attempts_persistence.py index f2381fc..8a2c87f 100644 --- a/tests/test_competitor_match_attempts_persistence.py +++ b/tests/test_competitor_match_attempts_persistence.py @@ -31,6 +31,11 @@ def test_competitor_feeder_persists_all_match_attempt_outcomes(): assert "run_expired_identity_refresh" in source assert "_fetch_retryable_candidate_skus" in source assert "run_retryable_candidate_revalidation" in source + retryable_source = source.split("def _fetch_retryable_candidate_skus", 1)[1].split( + "def _fetch_expired_identity_skus", 1 + )[0] + assert "la.attempt_status = 'low_score'" in retryable_source + assert "refresh_low_score')" not in retryable_source assert "refresh_known_identity" in source assert 'attempt_status="unit_comparable"' in source assert 'attempt_status="refresh_unit_comparable"' in source