[fix] solution/backend: 옛 테이블 이름 잔재로 빌더가 통째로 안 돌던 것

웹빌더가 세 자리에서 연달아 죽었다 — 가게 등록 · 수집 시작 · 수집 완료. 전부 같은 뿌리다:
DB 구조 재편이 테이블 이름을 옮기면서 **참조 세 종류 중 일부만** 따라갔다.

- **생성자 12군데** (`place_links(...)` → `place_channels(...)`)
  import 와 `DBType()` 은 고쳤는데 생성자를 빠뜨렸다. 클래스가 없어도 import 는 통과하므로
  기동은 정상이고, 그 줄이 실제로 실행되는 순간에만 터진다.
- **raw SQL 12군데** (`job.jobs` → `jobs`)
  잡 큐만 raw SQL 이라 ORM 이름 변경에 안 딸려 왔다. 큐가 안 도니 수집·비전·소개문·빌드·
  지역데이터가 하나도 못 들어간다. 화면에는 "버튼만 안 먹는" 것으로 보였다.
- **같은 이름의 속성 5군데** (`source.place_facts` → `source.facts` 등)
  이름만 보고 일괄 치환해 테이블과 무관한 자리까지 바뀌었다. `RawSource` 는 수집기 결과
  객체지 테이블이 아니다.
- **뗀 표를 계속 부르던 5군데** (`ai_check_results`)
  한 번도 쓰지 않아 마이그레이션이 뗀 표다. 부르면 SEO 진단이 통째로 죽는다.

★ 하나씩 터질 때마다 고치다가 멈추고 정적 검사로 남은 것을 한 번에 셌다 — pyflakes 가 19건을
  짚었다. 이 종류는 import 도 타입검사도 안 잡는다. 테이블 이름을 옮긴 뒤에는
  `python -m pyflakes services/ crud/ router/ worker/ common/ | grep "undefined name"` 을 돌린다.

검증: 직접 수집 실행(스테이,머뭄) — 잡 DONE · 재시도 0 · fact 2 · 사진 10 · 채널 2 저장.
정의 안 된 이름 0건.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 5 committed 2026-09-09 17:08:51 +09:00
1 parent c4af53613e
commit 387783b766
13 files changed
+56 -62

No files matched your search

+7 -7
View File
@@ -341,7 +341,7 @@ class PlaceService:
# 실측상 Perplexity 는 이 채널을 잘 못 찾는다 — 검증 단계에서 건지는 게 확실하다.
# 등록만 하고 확정하지는 않는다(확정은 수집 잡이 어댑터 유무를 보고 판단).
if (req.place_url or "").strip():
link = place_links(
link = place_channels(
place_id=uuid.UUID(place_id),
channel=LinkChannel.OFFICIAL_SITE.value,
url=req.place_url.strip(),
@@ -383,7 +383,7 @@ class PlaceService:
res.result.SetResult(err_type)
return res
unit = units(place_id=uuid.UUID(place_id), name=req.name.strip(), sort_order=req.sort_order)
unit = place_units(place_id=uuid.UUID(place_id), name=req.name.strip(), sort_order=req.sort_order)
run_err = await DB_SESSION_MNG.execute_lambda_run(
[place_units.DBType()],
[lambda s: self.crud.add_unit(s, unit)],
@@ -426,7 +426,7 @@ class PlaceService:
res.result.SetResult(err_type)
return res
link = place_links(
link = place_channels(
place_id=uuid.UUID(place_id),
channel=req.channel.value,
url=req.url.strip(),
@@ -572,18 +572,18 @@ class PlaceService:
res.result.SetResult(ErrorType.GENERATOR_NOT_CONFIGURED)
return res
conds = [media.place_id == uuid.UUID(place_id), media.deleted == False] # noqa: E712
conds = [place_photos.place_id == uuid.UUID(place_id), place_photos.deleted == False] # noqa: E712
if not req.force:
# ★ 미분석 기준은 alt_text 다 — label 은 수집 어댑터가 페이지 캡션으로 채운다.
# label 로 세면 캡션 있는 사진이 전부 '분석됨'으로 빠져 pending 0 이 된다
# (crud/media_crud.list_media 의 같은 주석 참고).
from sqlalchemy import func as sa_func
from sqlalchemy import or_ as sa_or
conds.append(sa_or(media.alt_text.is_(None), sa_func.btrim(media.alt_text) == ""))
conds.append(sa_or(place_photos.alt_text.is_(None), sa_func.btrim(place_photos.alt_text) == ""))
cnt_err, rows = await DB_SESSION_MNG.execute_lambda(
media.DBType(),
place_photos.DBType(),
DBWRType.DB_READ.value,
lambda s: DB_SESSION_MNG.execute(s, select(func.count()).select_from(media).where(*conds)),
lambda s: DB_SESSION_MNG.execute(s, select(func.count()).select_from(place_photos).where(*conds)),
)
res.pending_media = int(rows[0] or 0) if cnt_err == ErrorType.SUCCESS and rows else 0
if res.pending_media == 0: