feat(lps): price_history 몰별 최저가 스냅샷(by_mall JSONB)
몰이 열린 집합이라 와이드 컬럼(gmarket_*, st11_* …) 대신 JSONB 한 컬럼으로 담는다 — 몰 추가 시 마이그레이션 0. naver/coupang/final 3선 컬럼은 그래프 하위호환 유지. - models: price_history.by_mall JSONB 추가 - crud: record/list 에 by_mall 왕복(json.dumps + CAST jsonb) - handler: _price_snapshot 에 summarize_by_mall 적재, final 은 소스무관 전체 최저로 - protocol/service: history API 응답에 by_mall 노출 - migrations/2026-07-09: 기존 dev DB 동기화용 ALTER(추적 파일) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2eccf4de50
commit
3a2c6e43d4
7 files changed
+23
-7
No files matched your search
@@ -19,7 +19,7 @@ from common.enums import JobType
|
||||
from common.logger import LOG
|
||||
from services.search.contract import SearchAdapter, NormalizedProduct
|
||||
from services.search.util import parse_price
|
||||
from services.pipeline.core import apply_filters, rank_result
|
||||
from services.pipeline.core import apply_filters, rank_result, summarize_by_mall
|
||||
|
||||
|
||||
def _price_snapshot(matched: list[NormalizedProduct]) -> dict:
|
||||
@@ -29,13 +29,14 @@ def _price_snapshot(matched: list[NormalizedProduct]) -> dict:
|
||||
return min(items, key=lambda p: p.price) if items else None
|
||||
|
||||
n, c = lowest("naver"), lowest("coupang")
|
||||
finals = [x for x in (n, c) if x]
|
||||
f = min(finals, key=lambda p: p.price) if finals else None
|
||||
# 최종 최저가는 소스 무관 전체 매칭 중 최저(G마켓·옥션·11번가 등 폴백 포함).
|
||||
f = min(matched, key=lambda p: p.price) if matched else None
|
||||
return {
|
||||
"matched_count": len(matched),
|
||||
"naver_lowest": n.price if n else None, "naver_name": n.name if n else None, "naver_url": n.detail_url if n else None,
|
||||
"coupang_lowest": c.price if c else None, "coupang_name": c.name if c else None, "coupang_url": c.detail_url if c else None,
|
||||
"final_lowest": f.price if f else None, "final_source": f.source if f else None,
|
||||
"by_mall": summarize_by_mall(matched), # 몰별 최저가 스냅샷(열린 스키마)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user