feat: clinic registry DB + pipeline audit P0 fixes
## Clinic Registry - data/clinic-registry/clinic_registry_working.csv — 91개 병원 채널 마스터 DB - data/clinic-registry/INFINITH_Outbound_List.csv — BD팀 아웃바운드 리스트 (17컬럼) - data/clinic-registry/update_csv.py — 안전 CSV 업데이트 스크립트 (빈 필드만 채움) - data/clinic-registry/extract_place_ids.py — 네이버 플레이스 ID 추출기 - scripts/import-registry.ts — CSV → Supabase clinic_registry 테이블 임포트 - supabase/migrations/20260406_clinic_registry.sql — clinic_registry 테이블 스키마 ## Pipeline P0 Bug Fixes (전수 감사 후) - fix(collect-channel-data): 강남언니 rating 0-10 스케일 오변환 제거 - 기존: rating ≤ 5이면 ×2 → 4.8/10을 9.6/10으로 잘못 변환 - 수정: Firecrawl 프롬프트가 이미 0-10 지시 → rawValue 직접 신뢰 - fix(generate-report): Perplexity 단일 fetch → fetchWithRetry 교체 - maxRetries:2, backoffMs:[5000,15000], timeoutMs:90s - 기존: 타임아웃/429 시 리포트 생성 전체 실패 - 수정: 자동 재시도로 일시적 API 오류 극복 ## Docs - docs/PIPELINE_IMPROVEMENT_PLAN.md — Sprint 0/1/2 완료 표시 + 전수 감사 결과 추가 - docs/REGISTRY_FUNCTIONAL_SPECS.md, DB_SCHEMA_V3.md 외 기획 문서 다수 추가 ## New Components & Features - supabase/functions/generate-content-plan, adjust-strategy — 콘텐츠 플랜/전략 조정 - src/components/plan/EditEntryModal, StrategyAdjustmentSection — 플랜 편집 UI - supabase/functions/_shared/dataQuality, foundingYearExtractor, urlClassifier — 데이터 품질 유틸 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ec991057e6
commit
d5f7f24e0a
51 files changed
+5390
-252
No files matched your search
@@ -1,20 +1,22 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { useNavigate, useLocation, useParams } from 'react-router';
|
||||
import { motion } from 'motion/react';
|
||||
import { Check, AlertCircle, RefreshCw } from 'lucide-react';
|
||||
import { Check, AlertCircle, RefreshCw, ShieldX } from 'lucide-react';
|
||||
import {
|
||||
discoverChannels,
|
||||
collectChannelData,
|
||||
generateReportV2,
|
||||
generateContentPlan,
|
||||
fetchPipelineStatus,
|
||||
} from '../lib/supabase';
|
||||
|
||||
type Phase = 'resuming' | 'discovering' | 'collecting' | 'generating' | 'complete';
|
||||
type Phase = 'resuming' | 'discovering' | 'collecting' | 'generating' | 'planning' | 'complete';
|
||||
|
||||
const PHASE_STEPS = [
|
||||
{ key: 'discovering' as Phase, label: 'Scanning website & discovering channels...', labelDone: 'Channels discovered' },
|
||||
{ key: 'collecting' as Phase, label: 'Collecting channel data & market analysis...', labelDone: 'Data collected' },
|
||||
{ key: 'generating' as Phase, label: 'Generating AI marketing report...', labelDone: 'Report generated' },
|
||||
{ key: 'planning' as Phase, label: 'AI 콘텐츠 전략 생성 중...', labelDone: '콘텐츠 플랜 생성 완료' },
|
||||
{ key: 'complete' as Phase, label: 'Finalizing report...', labelDone: 'Complete' },
|
||||
];
|
||||
|
||||
@@ -49,6 +51,8 @@ function clearSession() {
|
||||
export default function AnalysisLoadingPage() {
|
||||
const [phase, setPhase] = useState<Phase>('discovering');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [errorCode, setErrorCode] = useState<string | null>(null);
|
||||
const [errorDomain, setErrorDomain] = useState<string | null>(null);
|
||||
const [errorDetails, setErrorDetails] = useState<Record<string, string> | null>(null);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
@@ -99,20 +103,35 @@ export default function AnalysisLoadingPage() {
|
||||
}
|
||||
|
||||
// Phase 3: Generate Report
|
||||
let reportResult: Record<string, unknown> | null = null;
|
||||
if (startPhase === 'generating') {
|
||||
setPhase('generating');
|
||||
const result = await generateReportV2(reportId, clinicId, runId);
|
||||
if (!result.success) throw new Error(result.error || 'Report generation failed');
|
||||
reportResult = result;
|
||||
startPhase = 'planning';
|
||||
}
|
||||
|
||||
// Phase 4: Generate Content Plan (non-blocking — failure doesn't stop pipeline)
|
||||
if (startPhase === 'planning') {
|
||||
setPhase('planning');
|
||||
try {
|
||||
await generateContentPlan(reportId, clinicId, runId);
|
||||
} catch (planErr) {
|
||||
console.warn('[pipeline] Content plan generation failed (non-blocking):', planErr);
|
||||
}
|
||||
|
||||
// Complete — navigate to report
|
||||
setPhase('complete');
|
||||
clearSession();
|
||||
|
||||
// Use stored report result or refetch
|
||||
const result = reportResult || await generateReportV2(reportId, clinicId, runId).catch(() => null);
|
||||
setTimeout(() => {
|
||||
navigate(`/report/${reportId}`, {
|
||||
replace: true,
|
||||
state: result.report && result.metadata
|
||||
? { report: result.report, metadata: result.metadata, reportId }
|
||||
state: result?.report && result?.metadata
|
||||
? { report: result.report, metadata: result.metadata, reportId, clinicId }
|
||||
: undefined,
|
||||
});
|
||||
}, 800);
|
||||
@@ -120,6 +139,12 @@ export default function AnalysisLoadingPage() {
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : 'An error occurred';
|
||||
setError(msg);
|
||||
if (err && typeof err === 'object' && 'code' in err) {
|
||||
setErrorCode((err as { code?: string }).code || null);
|
||||
}
|
||||
if (err && typeof err === 'object' && 'domain' in err) {
|
||||
setErrorDomain((err as { domain?: string }).domain || null);
|
||||
}
|
||||
}
|
||||
}, [navigate]);
|
||||
|
||||
@@ -260,41 +285,64 @@ export default function AnalysisLoadingPage() {
|
||||
)}
|
||||
|
||||
{error ? (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
className="w-full p-6 rounded-2xl bg-red-500/10 border border-red-500/20 text-center"
|
||||
>
|
||||
<AlertCircle className="w-10 h-10 text-red-400 mx-auto mb-3" />
|
||||
<p className="text-red-300 text-sm mb-4">{error}</p>
|
||||
|
||||
{errorDetails && (
|
||||
<div className="mb-4 text-left bg-red-500/5 rounded-lg p-3">
|
||||
<p className="text-red-400/60 text-xs font-mono mb-1">Failed channels:</p>
|
||||
{Object.entries(errorDetails).map(([ch, err]) => (
|
||||
<p key={ch} className="text-red-400/80 text-xs font-mono">
|
||||
• {ch}: {err}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-3 justify-center">
|
||||
<button
|
||||
onClick={handleRetry}
|
||||
className="px-6 py-2 text-sm font-medium text-white bg-purple-600/30 rounded-lg hover:bg-purple-600/50 transition-colors flex items-center gap-2"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4" />
|
||||
Retry
|
||||
</button>
|
||||
errorCode === 'CLINIC_NOT_REGISTERED' ? (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
className="w-full p-6 rounded-2xl bg-purple-500/10 border border-purple-500/20 text-center"
|
||||
>
|
||||
<ShieldX className="w-10 h-10 text-purple-400 mx-auto mb-3" />
|
||||
<p className="text-white text-lg font-medium mb-2">미등록 병원</p>
|
||||
<p className="text-purple-300/80 text-sm mb-1">
|
||||
<span className="font-mono text-purple-200">{errorDomain}</span>
|
||||
</p>
|
||||
<p className="text-purple-300/60 text-sm mb-6">
|
||||
현재 분석 대상 병원 목록에 포함되지 않은 도메인입니다.
|
||||
</p>
|
||||
<button
|
||||
onClick={() => { clearSession(); navigate('/', { replace: true }); }}
|
||||
className="px-6 py-2 text-sm font-medium text-white bg-white/10 rounded-lg hover:bg-white/20 transition-colors"
|
||||
className="px-6 py-2 text-sm font-medium text-white bg-purple-600/30 rounded-lg hover:bg-purple-600/50 transition-colors"
|
||||
>
|
||||
Start Over
|
||||
돌아가기
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
) : (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
className="w-full p-6 rounded-2xl bg-red-500/10 border border-red-500/20 text-center"
|
||||
>
|
||||
<AlertCircle className="w-10 h-10 text-red-400 mx-auto mb-3" />
|
||||
<p className="text-red-300 text-sm mb-4">{error}</p>
|
||||
|
||||
{errorDetails && (
|
||||
<div className="mb-4 text-left bg-red-500/5 rounded-lg p-3">
|
||||
<p className="text-red-400/60 text-xs font-mono mb-1">Failed channels:</p>
|
||||
{Object.entries(errorDetails).map(([ch, err]) => (
|
||||
<p key={ch} className="text-red-400/80 text-xs font-mono">
|
||||
• {ch}: {err}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-3 justify-center">
|
||||
<button
|
||||
onClick={handleRetry}
|
||||
className="px-6 py-2 text-sm font-medium text-white bg-purple-600/30 rounded-lg hover:bg-purple-600/50 transition-colors flex items-center gap-2"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4" />
|
||||
Retry
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { clearSession(); navigate('/', { replace: true }); }}
|
||||
className="px-6 py-2 text-sm font-medium text-white bg-white/10 rounded-lg hover:bg-white/20 transition-colors"
|
||||
>
|
||||
Start Over
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
)
|
||||
) : (
|
||||
<>
|
||||
{phase === 'resuming' ? (
|
||||
|
||||
Reference in new issue
Block a user