feat(performance): 매출 업데이트 취소 버튼

- 진행 창 [업데이트 취소](시작한 사람·관리자) → POST /api/sync/jobs/{id}/cancel
- 어댑터가 API 호출 직전마다 ctx.progress.check() — 취소면 Cancelled 로 멈추고 저장하지 않음(기존 매출 그대로),
  차례가 안 온 쇼핑몰은 취소됨으로 건너뜀, 이미 끝난 쇼핑몰 결과는 유지
- 취소 실행은 perf_sync_runs failed + 업데이트 취소, 연결 상태는 바꾸지 않음
- 테스트 1개 추가(30개 통과), performance.js/css 캐시 버전, 문서 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 15:06:25 +09:00
parent 8b3e6dffc5
commit da63b93302
14 changed files with 178 additions and 21 deletions
+11 -1
View File
@@ -32,6 +32,7 @@ STATUS_LABELS: dict[str, str] = {
"not_implemented": "연동 준비 중",
"unknown": "확인 전",
"disabled": "사용 중지", # DB 에는 저장하지 않는 화면 전용 상태(쇼핑몰 사용 OFF)
"cancelled": "취소됨", # 화면 전용 — 매출 업데이트 창에서 [업데이트 취소](연결 상태는 바꾸지 않음)
}
EVENT_TYPES = ("SALE", "CANCEL", "RETURN", "ADJUST")
@@ -68,6 +69,11 @@ class NotImplementedYet(AdapterError):
status = "not_implemented"
class Cancelled(AdapterError):
"""사용자가 매출 업데이트를 취소함 — 어댑터가 ctx.progress.check() 에서 받는다. 연결 오류가 아니다."""
status = "cancelled"
# ════════════════════════════════════════════════════════════
# 설정 입력칸 · 공통 매출 사건
# ════════════════════════════════════════════════════════════
@@ -135,7 +141,8 @@ class Progress:
객체(jobs.ShopProgress)로 바꿔 넣는다.
어댑터: 조회를 시작하기 전에 plan(전체 단계 수, 단위) → 단계 하나(하루·조회 구간)를 끝낼 때마다
step(items=그 단계에서 받은 건수). 하다가 할 일이 늘면 add(늘어난 단계 수)."""
step(items=그 단계에서 받은 건수). 하다가 할 일이 늘면 add(늘어난 단계 수).
API 를 부르기 직전마다 check() — 사용자가 [업데이트 취소]를 눌렀으면 Cancelled 를 던져 거기서 멈춘다."""
def plan(self, total: int, unit: str = "단계") -> None:
return None
@@ -146,6 +153,9 @@ class Progress:
def step(self, n: int = 1, *, items: int = 0) -> None:
return None
def check(self) -> None:
return None
@dataclass
class AdapterContext:
@@ -291,6 +291,7 @@ class Cafe24Adapter(MarketplaceAdapter):
if offset > MAX_OFFSET:
raise ApiError(f"카페24 조회 건수가 너무 많습니다({params.get('start_date')}~{params.get('end_date')}). "
"기간을 줄여 다시 시도하세요.")
ctx.progress.check() # [업데이트 취소]면 여기서 멈춤
rows = self._get(ctx, path, {**params, "limit": limit, "offset": offset}).get(key) or []
yield from rows
if len(rows) < limit:
@@ -270,6 +270,7 @@ class ElevenstAdapter(MarketplaceAdapter):
def _get(self, ctx: AdapterContext, path: str) -> bytes:
import httpx # 지연 import
ctx.progress.check() # [업데이트 취소]면 여기서 멈춤
headers = {"openapikey": ctx.credentials.get("api_key").strip(), "Accept": "application/xml"}
try:
res = httpx.get(f"{HOST}{path}", headers=headers, timeout=ctx.timeout_sec)
@@ -166,6 +166,7 @@ class GsshopAdapter(MarketplaceAdapter):
from app.timezone import now_kst # noqa: WPS433
ctx.progress.check() # [업데이트 취소]면 여기서 멈춤
sup, key = self._creds(ctx)
key_bytes = dict(key_variants(key))[how[0]]
headers = {"supCd": sup, "token": make_token(key_bytes, sup, now_kst(), how[1]), "Accept": "application/json"}
@@ -298,6 +298,7 @@ class NaverAdapter(MarketplaceAdapter):
retried_auth = False
for attempt in range(RETRY_429 + 1):
ctx.progress.check() # [업데이트 취소]면 여기서 멈춤
wait = CALL_INTERVAL_SEC - (time.monotonic() - self._last_call)
if wait > 0:
time.sleep(wait)