/** 수집·분석·소개문 잡이 끝났을 때의 알림 문구. */ import type {JobData} from '@/api'; import {notify} from '@/lib/notify'; import {readGroup, readNote, readNumber} from './collectJobResult'; /** 재수집(정보) 결과 알림. */ export function notifyCollected(job: JobData) { const facts = readGroup(job, 'facts'); const media = readGroup(job, 'media'); const stored = readNumber(facts, 'stored'); const candidate = readNumber(facts, 'candidate'); const refreshed = readNumber(facts, 'refreshed'); const photos = readNumber(media, 'stored'); if (stored === 0 && photos === 0) { notify.warn( '새로 들어온 정보가 없습니다.', readNote(job) ?? '확정된 채널에서 달라진 값을 찾지 못했습니다.', ); return; } const parts = [`확인할 새 값 ${candidate}건`, `그대로인 값 ${refreshed}건`]; if (photos > 0) parts.push(`새 사진 ${photos}장`); notify.success( '다시 수집했습니다', `${parts.join(' · ')} — 새 값은 [맞아요]를 눌러야 사이트에 나갑니다.`, ); } /** 재분석(사진) 결과 알림. */ export function notifyVision(job: JobData) { const analyzed = readNumber(job.result, 'analyzed'); if (analyzed === 0) { notify.warn('분석한 사진이 없습니다.', readNote(job) ?? '수집된 사진이 없습니다.'); return; } notify.success( '사진을 다시 분석했습니다', `${analyzed}장 · 자동 반영 ${readNumber(job.result, 'approved')}장 · ` + `확인 대기 ${readNumber(job.result, 'needs_review')}장`, ); } /** 재생성(소개문·FAQ) 결과 알림. */ export function notifyCopy(job: JobData) { const faqCount = readNumber(job.result, 'faqs'); const fillCount = readNumber(job.result, 'faq_fill'); const hasIntro = (job.result as {intro?: unknown} | undefined)?.intro === true; if (!hasIntro && faqCount === 0 && fillCount === 0) { notify.warn( '새로 만든 문장이 없습니다.', readNote(job) ?? '근거로 쓸 확인된 정보가 부족합니다. 정보를 먼저 확인해 주세요.', ); return; } const parts = [`소개문 ${hasIntro ? '1건' : '없음'}`, `FAQ ${faqCount}건`]; if (fillCount > 0) parts.push(`문의 안내 ${fillCount}건`); notify.success( '소개문·FAQ 를 다시 만들었습니다', `${parts.join(' · ')} — FAQ 탭에서 확인할 수 있습니다.`, ); }