feat(lps): 오픈마켓 폴백 오케스트레이션 + 몰 dedup

사용자 규칙 '네이버로 그 몰 값 확보 성공→그 값, 실패(몰 없음)→실사이트 크롤' 구현.

- handler: found 라운드 뒤 _enrich_with_fallback — 네이버 매칭이 커버 못 한 타깃 몰만
  (canonical_mall 로 판정) 크롤 어댑터로 검색→같은상품 판정→병합. 크롤 실패는 격리(무시).
  fallback_crawl STAGE 기록.
- summarize_by_mall: 키를 (source,mall)→몰명(canonical)으로 — 네이버노출 vs 직접크롤 같은 몰
  중복을 최저가 1건으로 병합(dedup).
- card_parser: MALL_BY_SOURCE + canonical_mall() 추가.
- worker_main: gmarket/auction/st11 폴백 어댑터 등록(lazy 기동, 리소스차단 OFF).
- 테스트: 커버몰 크롤생략·미커버 크롤·실패격리·몰 dedup 4종.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Fable 5 committed 2026-07-09 14:45:39 +09:00
1 parent e365e5c6e0
commit f9714c3f06
5 files changed
+108 -11

No files matched your search

+6 -6
View File
@@ -52,13 +52,13 @@ def apply_filters(
def summarize_by_mall(products: list[NormalizedProduct]) -> list[dict]:
"""같은상품 매칭 후보를 (소스, 판매몰)별 최저가로 분해한다.
네이버 결과엔 G마켓·옥션·11번가 등이 mall_name 으로 이미 들어오므로,
추가 요청 없이 '오픈마켓 몰별 최저가'를 노출할 수 있다(가격 오름차순).
네이버 가격비교(mall_name='네이버')는 여러 판매자 중 최저가 롤업이다."""
best: dict[tuple[str, str], NormalizedProduct] = {}
"""같은상품 매칭 후보를 판매몰별 최저가로 분해한다(가격 오름차순).
네이버 결과엔 G마켓·옥션·11번가 등이 mall_name 으로 이미 들어오고, 크롤 폴백도 같은 몰명을 쓴다.
**몰명(canonical)으로 dedup** — 같은 몰이 네이버 노출과 직접 크롤 양쪽에서 와도 최저가 1건으로 병합
(네이버 가격비교 mall_name='네이버'는 여러 판매자 최저가 롤업이라 별도 몰로 취급)."""
best: dict[str, NormalizedProduct] = {}
for p in products:
key = (p.source, (p.mall_name or "기타"))
key = p.mall_name or p.source or "기타" # 몰 정체성 = 몰명(소스 무관 병합)
cur = best.get(key)
if cur is None or p.price < cur.price:
best[key] = p
+8
View File
@@ -12,6 +12,14 @@ from selectolax.parser import HTMLParser
from services.search.contract import NormalizedProduct
from services.search.util import extract_price, clean_name, shipping_from_text
# 소스 코드 → 표시 몰명(canonical). 폴백 커버리지 판정·dedup 에 쓴다.
MALL_BY_SOURCE = {"naver": "네이버", "coupang": "쿠팡", "gmarket": "G마켓", "auction": "옥션", "st11": "11번가"}
def canonical_mall(product) -> str:
"""상품의 판매몰 정체성(몰명 우선, 없으면 소스 매핑)."""
return product.mall_name or MALL_BY_SOURCE.get(product.source, product.source)
@dataclass(frozen=True)
class CardConfig: