feat(negodata): 4단계 — 사용자 화면에서 '없음'과 '확인 못함'을 구분
마지막 단계. 차단당해 못 본 몰이 화면에서 '–'(없음)로 보여 사용자가 "쿠팡엔 더 싼 게 없구나"로 오해하던 문제를 끝낸다. 안 본 걸 없다고 말하지 않는다. 사용자 화면은 **셋으로 접는다**(lps/docs/result-states.md 3-2절). 할 수 있는 행동이 '쓴다/다시 시도/넘어간다' 뿐이라, 원인이 달라도 다음 행동이 같으면 같은 표기다: matched → 가격 no_match · empty → '–' (확인했고 없었다) blocked · env_blocked · unavailable → '확인 못함' (못 봤다) 운영자 화면(lps-admin)은 같은 데이터로 7상태를 그대로 본다 — 목적이 진단이라 접지 않는다. 체인 전체를 이었다: - postgres-init/alters/2026-08-07-iilp-source-state.sql — item_internet_lowest_prices 에 sources/partial 추가(멱등, **운영 적용 필요**) - models.py / lps_sync_crud 읽기 계약 / lps_sync_service 미러링 / LowestPriceEntry 프로토콜 - orval 재생성(ORVAL_INPUT 으로 저장 스펙에서 — 서버 없이). 생성 diff 는 새 필드만. - PriceUpdateModal: 가격이 없는 몰이 '못 본 몰'이면 '–' 대신 '확인 못함'. partial 은 LPS 가 판단해 내려준 사실을 그대로 쓴다 — 화면이 '어떤 상태가 확인된 것인가'를 다시 판정하면 상태 정의가 LPS 와 negodata 두 곳으로 흩어진다. E2E 검증(실 DB 2시나리오): by_mall 은 둘 다 naver 뿐인데 쿠팡 칸이 '확인 못함'(차단) / '–'(0건) 으로 갈린다. tsc 오류 없음(기존 xlsx 미설치 오류는 무관). negodata 97 · lps 292 passed. > 폴더 관례상 negodata 는 인수인계 대상이나, 사용자 요청으로 이번 건도 예외 적용. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1d1ed6ec5
commit
95086cb3f6
12 files changed
+176
-14
No files matched your search
@@ -92,6 +92,8 @@ export * from './lowestPriceEntryFailReason';
|
||||
export * from './lowestPriceEntryLpName';
|
||||
export * from './lowestPriceEntryLpPrice';
|
||||
export * from './lowestPriceEntryLpUrl';
|
||||
export * from './lowestPriceEntrySources';
|
||||
export * from './lowestPriceEntrySourcesAnyOf';
|
||||
export * from './notificationData';
|
||||
export * from './notificationDataCreatedAt';
|
||||
export * from './notificationDataData';
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { LowestPriceEntryFailReason } from './lowestPriceEntryFailReason';
|
||||
import type { LowestPriceEntryLpName } from './lowestPriceEntryLpName';
|
||||
import type { LowestPriceEntryLpUrl } from './lowestPriceEntryLpUrl';
|
||||
import type { LowestPriceEntryByMall } from './lowestPriceEntryByMall';
|
||||
import type { LowestPriceEntrySources } from './lowestPriceEntrySources';
|
||||
import type { LowestPriceEntryCrawlEndTime } from './lowestPriceEntryCrawlEndTime';
|
||||
|
||||
/**
|
||||
@@ -22,5 +23,7 @@ export interface LowestPriceEntry {
|
||||
lp_name?: LowestPriceEntryLpName;
|
||||
lp_url?: LowestPriceEntryLpUrl;
|
||||
by_mall?: LowestPriceEntryByMall;
|
||||
sources?: LowestPriceEntrySources;
|
||||
partial?: boolean;
|
||||
crawl_end_time?: LowestPriceEntryCrawlEndTime;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { LowestPriceEntrySourcesAnyOf } from './lowestPriceEntrySourcesAnyOf';
|
||||
|
||||
export type LowestPriceEntrySources = LowestPriceEntrySourcesAnyOf | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type LowestPriceEntrySourcesAnyOf = { [key: string]: unknown };
|
||||
@@ -9,6 +9,7 @@ import { Typography } from '@/components/ui/typography';
|
||||
import { useScrollLock } from '@/lib/useScrollLock';
|
||||
import { triggerLowestPrice, getLowestPrice } from '@/api/generated/item/item';
|
||||
import type { LowestPriceEntryByMall } from '@/api/generated/model/lowestPriceEntryByMall';
|
||||
import type { LowestPriceEntrySources } from '@/api/generated/model/lowestPriceEntrySources';
|
||||
import type { Product } from '../types';
|
||||
|
||||
type PriceUpdateModalProps = {
|
||||
@@ -35,9 +36,24 @@ const SOURCES = [
|
||||
{ key: 'coupang', label: '쿠팡' },
|
||||
] as const;
|
||||
|
||||
// 몰별 최저가 = by_mall 을 source 로 묶어 최저가만 남긴 것. 값이 없으면 그 몰은 못 찾은 것.
|
||||
// 몰별 최저가 = by_mall 을 source 로 묶어 최저가만 남긴 것.
|
||||
type MallPrices = Record<string, number>;
|
||||
|
||||
// 값이 없는 몰은 두 경우다 — '거기엔 없었다'와 '거기를 못 봤다'. 뜻이 정반대라 같이 보이면 안 된다.
|
||||
// 사용자가 할 수 있는 건 '쓴다 / 다시 시도 / 넘어간다' 뿐이라, 원인이 달라도 다음 행동이 같으면
|
||||
// 같은 표기로 접는다(운영자 화면 lps-admin 은 7상태를 그대로 본다).
|
||||
// matched → 가격
|
||||
// no_match · empty → '–' (결론은 '이 몰엔 없다')
|
||||
// blocked · env_blocked · unavailable → '확인 못함' (행동은 '나중에 다시' 하나뿐)
|
||||
// 상태 정의는 lps/docs/result-states.md.
|
||||
const CONFIRMED_STATES = new Set(['matched', 'no_match', 'empty', 'skipped']);
|
||||
|
||||
/** 그 몰을 확인하지 못했는가(=가격 자리에 '–' 대신 '확인 못함'을 써야 하는가). */
|
||||
const isUnconfirmed = (sources: LowestPriceEntrySources | undefined, source: string): boolean => {
|
||||
const state = (sources as Record<string, { state?: string }> | null | undefined)?.[source]?.state;
|
||||
return !!state && !CONFIRMED_STATES.has(state);
|
||||
};
|
||||
|
||||
const toMallPrices = (byMall: LowestPriceEntryByMall): MallPrices => {
|
||||
const out: MallPrices = {};
|
||||
for (const entry of byMall ?? []) {
|
||||
@@ -52,8 +68,8 @@ const toMallPrices = (byMall: LowestPriceEntryByMall): MallPrices => {
|
||||
// 상품 1건의 처리 상태(화면 전체 상태와 구분해 ItemState 로 둔다).
|
||||
type ItemState =
|
||||
| { kind: 'pending' } // 접수됨 — 결과 대기
|
||||
| { kind: 'done'; price: number; malls: MallPrices }
|
||||
| { kind: 'notfound'; malls: MallPrices } // 검색은 됐으나 같은 상품이 없었음(기존 값 유지)
|
||||
| { kind: 'done'; price: number; malls: MallPrices; unconfirmed?: string[] }
|
||||
| { kind: 'notfound'; malls: MallPrices; unconfirmed?: string[] } // 검색은 됐으나 같은 상품이 없었음(기존 값 유지)
|
||||
| { kind: 'failed'; reason?: string } // 접수 실패 또는 검색 실패(사이트 차단) — 재시도 대상
|
||||
| { kind: 'timeout' } // 폴링 상한 초과 — 서버는 계속 검색 중
|
||||
| { kind: 'stopped' }; // 사용자가 지켜보기를 중단 — 서버는 계속 검색 중
|
||||
@@ -249,13 +265,15 @@ export function PriceUpdateModal({ open, products, selectedIds, onDone, onClose
|
||||
if (!fresh) continue;
|
||||
pending.delete(id);
|
||||
const malls = toMallPrices(fresh.by_mall ?? null);
|
||||
// 가격 자리에 '–'(없음) 대신 '확인 못함'을 써야 하는 몰들
|
||||
const unconfirmed = SOURCES.map((x) => x.key).filter((m) => isUnconfirmed(fresh.sources, m));
|
||||
if (fresh.success_yn && fresh.lp_price != null) {
|
||||
found += 1;
|
||||
const prev = prevPriceOf(id);
|
||||
if (prev <= 0 || fresh.lp_price < prev) succeeded.add(id); // 값이 실제로 갱신된 행
|
||||
// by_mall 이 비어 오는 옛 이력 대비 — 최소한 대표 최저가는 보이도록 폴백을 채운다.
|
||||
if (Object.keys(malls).length === 0) malls.etc = fresh.lp_price;
|
||||
setItem(id, { kind: 'done', price: fresh.lp_price, malls });
|
||||
setItem(id, { kind: 'done', price: fresh.lp_price, malls, unconfirmed });
|
||||
} else if (fresh.fail_reason === 'error') {
|
||||
// 검색 자체가 실패한 경우(모든 소스 차단). '못 찾음'과 뜻이 완전히 다르다 —
|
||||
// 상품이 없다는 게 아니라 **확인을 못 했다**는 뜻이라, 재시도 대상으로 분류한다.
|
||||
@@ -264,7 +282,7 @@ export function PriceUpdateModal({ open, products, selectedIds, onDone, onClose
|
||||
// 문구는 '탐색 실패 사유: {reason}' 형태로 붙는다 — 사유만 간결하게 담는다.
|
||||
setItem(id, { kind: 'failed', reason: '사이트 차단으로 가격을 확인하지 못했습니다 (잠시 후 다시 시도해 주세요)' });
|
||||
} else {
|
||||
setItem(id, { kind: 'notfound', malls });
|
||||
setItem(id, { kind: 'notfound', malls, unconfirmed });
|
||||
}
|
||||
} catch {
|
||||
/* 일시 오류는 다음 tick 재시도 */
|
||||
@@ -311,7 +329,13 @@ export function PriceUpdateModal({ open, products, selectedIds, onDone, onClose
|
||||
const prices = Object.values(malls);
|
||||
const best = prices.length > 0 ? Math.min(...prices) : null;
|
||||
const price = malls[source];
|
||||
if (price === undefined) return <span className="text-muted-foreground">–</span>;
|
||||
if (price === undefined) {
|
||||
// 안 본 걸 '없음(–)'으로 보여주면 사용자는 '이 몰엔 더 싼 게 없다'로 읽는다 — 사실이 아니다.
|
||||
const unseen = (s.kind === 'done' || s.kind === 'notfound') && s.unconfirmed?.includes(source);
|
||||
return unseen
|
||||
? <span className="text-amber-600" title="사이트 차단 등으로 이 몰의 가격을 확인하지 못했습니다">확인 못함</span>
|
||||
: <span className="text-muted-foreground">–</span>;
|
||||
}
|
||||
const isBest = price === best;
|
||||
return (
|
||||
<span className={isBest ? 'font-semibold text-foreground' : 'text-muted-foreground'}>
|
||||
|
||||
Reference in new issue
Block a user