refactor(negodata): LPS 자동 요청 배치 제거 — 검색은 수동 트리거 전용
협의 결정(2026-07-10): 크롤 비용이 사용자 행동에만 비례하도록,
갱신 오래된 상품을 자동으로 검색 요청하던 잡(매일 04:00, 상한 500건,
일 ~$2)을 제거한다. 검색 진입점은 상품 화면의 수동 트리거
(POST /v1/item/{id}/lowest-price) 하나만 남는다.
- request_lps_searches 잡·request_stale_searches 서비스·stale_items
CRUD·배치 상수(REFRESH_HOURS 등) 제거
- 수집 잡(sync_lps_results, 5분)은 유지 — 크롤을 일으키지 않는
반영 백스톱(모달 조기 종료·폴링 초과분 자동 반영, 비용 0)
검증: 스케줄러 등록 잡 3개(견적마감 2 + LPS 수집 1) 확인, 수집 잡 실행 정상
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3171311746
commit
5ddf5f6249
4 files changed
+16
-119
No files matched your search
@@ -10,7 +10,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Tuple
|
||||
|
||||
from sqlalchemy import column, func, or_, select, table, update
|
||||
from sqlalchemy import column, func, select, table, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
@@ -34,10 +34,6 @@ class ILpsSyncCRUD(ABC):
|
||||
async def watermark(self, cdb: AsyncSession) -> Tuple[ErrorType, object]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def stale_items(self, cdb: AsyncSession, cutoff, limit) -> Tuple[ErrorType, list]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def existing_item_ids(self, cdb: AsyncSession, item_ids: list) -> Tuple[ErrorType, set]:
|
||||
pass
|
||||
@@ -72,34 +68,6 @@ class LpsSyncCRUD(ILpsSyncCRUD):
|
||||
LOG.e_no_callstack(f"[lps-sync] watermark 조회 실패: {ex}")
|
||||
return ErrorType.DB_RUN_FAILED, None
|
||||
|
||||
async def stale_items(self, cdb: AsyncSession, cutoff, limit: int):
|
||||
"""재검색 대상 상품 — 수집 이력이 없거나 마지막 수집이 cutoff 이전인 활성 상품.
|
||||
반환 행: (item_id, name, model_name, spec, manufacturer, price)"""
|
||||
try:
|
||||
latest = (
|
||||
select(
|
||||
item_internet_lowest_prices.item_id.label("item_id"),
|
||||
func.max(item_internet_lowest_prices.crawl_end_time).label("last_ts"),
|
||||
)
|
||||
.where(item_internet_lowest_prices.deleted == False) # noqa: E712
|
||||
.group_by(item_internet_lowest_prices.item_id)
|
||||
.subquery()
|
||||
)
|
||||
q = (
|
||||
select(items.item_id, items.name, items.model_name, items.spec, items.manufacturer, items.price)
|
||||
.join(latest, items.item_id == latest.c.item_id, isouter=True)
|
||||
.where(
|
||||
items.deleted == False, # noqa: E712
|
||||
or_(latest.c.last_ts.is_(None), latest.c.last_ts < cutoff),
|
||||
)
|
||||
.order_by(latest.c.last_ts.asc().nullsfirst()) # 오래된 것부터(이력 없는 신규 최우선)
|
||||
.limit(limit)
|
||||
)
|
||||
return ErrorType.SUCCESS, (await cdb.execute(q)).all()
|
||||
except Exception as ex:
|
||||
LOG.e_no_callstack(f"[lps-sync] stale_items 조회 실패: {ex}")
|
||||
return ErrorType.DB_RUN_FAILED, []
|
||||
|
||||
async def existing_item_ids(self, cdb: AsyncSession, item_ids: list):
|
||||
"""전달된 id 중 실재하는 활성 상품 id 집합 — 결과 반영 전 매핑 검증용."""
|
||||
if not item_ids:
|
||||
|
||||
Reference in new issue
Block a user