[feat] solution/backend,frontend,site: 수집·사진 분석·발행 진행을 Teams 로 발송 — 수집 중 배포에도 사진 목록 복구

컨테이너를 재생성하면 docker logs 가 사라져 크롤링이 잘 됐는지 확인할 방법이 없었다.
실측(09-30 버터브루): 수집 도중 배포로 API 가 80초 끊기자 화면이 사진 분석 폴링을
3회 실패 후 포기해 사진 10장이 DB 에 있는데도 0장으로 보였다.

- services/activity_feed.py: 기존 alert_outbox·장애 채널로 kind=activity 이벤트 적재(중복 억제 없음)
- collect_service: 수집 시작 · 채널 크롤링 실패 즉시 · 완료 요약(채널별·fact·사진·누락 필수항목·소요초) · 실패
- vision_service: 사진 분석 결과
- build_service · rollback_service: 첫 발행/재발행/빌드만/되돌리기 시작·끝 — URL · 굽기 사진 미러링 수
- site/prerender.ts: 렌더 보고서에 사진 미러링 수(media) 추가
- frontend pollJob: 연속 3회 실패여도 3분간 무응답일 때만 unreachable
- frontend collectJobs: 사진 분석 폴링을 못 끝내도 사진 목록을 다시 읽고 경고
- test_build_publish: 게이트 반려 검사에서 activity 이벤트는 제외

관련 테스트 17개 파일 295 passed · 2 failed(test_search_console_service — 변경 전에도 실패)
frontend tsc·eslint, site tsc·eslint 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 5.5 committed 2026-09-30 15:09:52 +09:00
1 parent e5153eb66c
commit 87343c791b
9 files changed
+178 -11

No files matched your search

+51 -1
View File
@@ -1,5 +1,6 @@
"""정적 빌드 + 발행 — BUILD 잡이 하는 일."""
import os
import time
import uuid
from sqlalchemy import select
@@ -25,6 +26,7 @@ from crud.site_crud import SiteCRUD
from crud.place_crud import PlaceCRUD
from crud.post_crud import PostCRUD
from services import (
activity_feed,
alert_service,
azure_static,
indexnow,
@@ -118,6 +120,45 @@ async def _log(site_id, version_id, action: PublishAction, result: PublishResult
async def run_build(job: dict) -> dict:
"""BUILD 잡 핸들러."""
started = time.monotonic()
try:
result = await _run_build(job)
except Exception as ex:
await activity_feed.post(
"❌ 빌드 실패",
[f"place_id={job['payload'].get('place_id')}", f"{type(ex).__name__}: {ex}",
f"{time.monotonic() - started:.0f}초"],
)
raise
await post_build_summary(result, time.monotonic() - started)
return result
async def post_build_summary(result: dict, elapsed: float) -> None:
version = f"v{result.get('version')}"
mode = result.get("mode") or "빌드"
lines = [f"{result.get('label') or result.get('place_id')} {version}"]
if result.get("build_status") == "BUILT":
title = f"✅ {mode} 완료"
if result.get("url"):
lines.append(result["url"])
elif result.get("gate", {}).get("passed") is False:
title = f"🚫 {mode} 반려(게이트)"
lines.append(str(result.get("error") or ""))
else:
title = f"❌ {mode} 실패"
lines.append(str(result.get("error") or ""))
media = result.get("render_media")
if media:
lines.append(
f"굽기 — 사진 {media.get('total', 0)}장: 새로 받음 {media.get('fetched', 0)} · "
f"기존 {media.get('cached', 0)} · 실패 {media.get('failed', 0)}"
)
lines.append(f"{elapsed:.0f}초")
await activity_feed.post(title, lines)
async def _run_build(job: dict) -> dict:
payload = job["payload"]
place_id = payload["place_id"]
owner_user_id = payload["owner_user_id"]
@@ -132,6 +173,7 @@ async def run_build(job: dict) -> dict:
raise BuildAborted(f"사업장을 찾을 수 없다: {place_id}")
site = await ensure_site(place_id)
mode = ("재발행" if site.published_at is not None else "첫 발행") if want_publish else "빌드만"
# 주변 정보(맛집·관광지·축제·코스)는 빌드 시점에 업장 좌표로 새로 받는다 — 발행본은 정적이라 이때 받은 값이 실린다.
try:
@@ -198,7 +240,12 @@ async def run_build(job: dict) -> dict:
raise BuildAborted(f"버전 생성 실패: {add_err.name}")
result = {"place_id": place_id, "site_id": str(site.site_id), "version": version_no,
"site_version_id": str(version.site_version_id)}
"site_version_id": str(version.site_version_id), "label": activity_feed.place_label(place),
"mode": mode}
await activity_feed.post(
f"🏗 {mode} 시작",
[f"{result['label']} v{version_no}", f"템플릿 {site.template_id or '기본'}"],
)
# 잡 결과에 남긴다 — "노래가 왜 없나" 를 잡 하나만 열어 보면 알 수 있어야 한다.
if song_result is not None:
result["song"] = song_result
@@ -267,6 +314,8 @@ async def run_build(job: dict) -> dict:
# 발행하지 않는다.
return await _fail(str(ex))
if report.get("media"):
result["render_media"] = report["media"]
mismatches = list(report.get("mismatches") or [])
unique_count_raw = report.get("uniqueContentCount")
unique_count = unique_count_raw or 0
@@ -366,6 +415,7 @@ async def run_build(job: dict) -> dict:
if thumbnail_url:
site.thumbnail_url = thumbnail_url
result["published"] = True
result["url"] = site_payload.publish_url(place, site)
LOG.i(f"[build] place={place_id} v{version_no} 발행 완료 "
f"(고유 콘텐츠 {unique_count}건 · {report.get('routes')} 페이지)")
else: