[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:
1 parent
c4af53613e
commit
387783b766
13 files changed
+56
-62
No files matched your search
@@ -30,8 +30,8 @@ class CollectAborted(RuntimeError):
|
||||
async def _add_link(place_id: str, channel, url: str, title: str, discovered_by, raw=None) -> bool:
|
||||
"""링크 한 건 적재. 이미 있으면 False(유니크 충돌은 재수집의 정상 경로다)."""
|
||||
err = await DB_SESSION_MNG.execute_lambda_run(
|
||||
[place_links.DBType()],
|
||||
[lambda s: _place_crud.add_link(s, place_links(
|
||||
[place_channels.DBType()],
|
||||
[lambda s: _place_crud.add_link(s, place_channels(
|
||||
place_id=uuid.UUID(place_id), channel=channel.value, url=url, title=title,
|
||||
discovered_by=discovered_by.value, discovered_at=GTime.UTC(), raw=raw,
|
||||
))],
|
||||
@@ -82,7 +82,7 @@ async def discover_naver_place(place, place_id: str) -> str:
|
||||
# 근거가 사람 확인과 같은 수준이므로 클릭을 한 번 더 받는 것은 이득 없이 막기만 한다 —
|
||||
# 실제로 이 클릭 때문에 힐튼·도플로가 "수집했는데 0건"으로 끝났다.
|
||||
err, _rows = await DB_SESSION_MNG.execute_lambda_claim(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
lambda s: _place_crud.confirm_link_by_url(s, uuid.UUID(place_id), url, place.verified_by, GTime.UTC()),
|
||||
)
|
||||
LOG.i(f"[collect] 네이버 플레이스 링크 {'등록·확정' if added else '확정'} — place {place_id_naver}")
|
||||
@@ -128,7 +128,7 @@ async def discover_tour_api(place, place_id: str) -> str:
|
||||
place_id, LinkChannel.ETC, url, f"{place.name} 한국관광공사 TourAPI", SourceType.API,
|
||||
)
|
||||
err, _rows = await DB_SESSION_MNG.execute_lambda_claim(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
lambda s: _place_crud.confirm_link_by_url(s, uuid.UUID(place_id), url, place.verified_by, GTime.UTC()),
|
||||
)
|
||||
LOG.i(f"[collect] TourAPI 링크 {'등록·확정' if added else '확정'} — contentId {content_id}")
|
||||
@@ -136,7 +136,7 @@ async def discover_tour_api(place, place_id: str) -> str:
|
||||
|
||||
|
||||
async def discover_links(place, place_id: str, *, include_perplexity: bool = False) -> dict:
|
||||
"""채널 URL 을 찾아 place_links 에 적재한다(미확정 상태).
|
||||
"""채널 URL 을 찾아 place_channels 에 적재한다(미확정 상태).
|
||||
|
||||
★ 순서가 곧 신뢰도다. 지금 자동 발견 경로는 **네이버 플레이스 직접 해석 하나뿐**이고,
|
||||
Perplexity 는 사용자가 추가 채널 탐색 옵션을 고른 회차에만 실행한다.
|
||||
@@ -198,7 +198,7 @@ async def discover_links(place, place_id: str, *, include_perplexity: bool = Fal
|
||||
stat["filtered_out"] = found.reason_counts()
|
||||
now = GTime.UTC()
|
||||
for link in found.links:
|
||||
row = place_links(
|
||||
row = place_channels(
|
||||
place_id=uuid.UUID(place_id),
|
||||
channel=link.channel.value,
|
||||
url=link.url,
|
||||
@@ -208,7 +208,7 @@ async def discover_links(place, place_id: str, *, include_perplexity: bool = Fal
|
||||
raw=found.raw, # 본문 + search_results 원문 — 환각 추적용
|
||||
)
|
||||
err = await DB_SESSION_MNG.execute_lambda_run(
|
||||
[place_links.DBType()],
|
||||
[place_channels.DBType()],
|
||||
[lambda s, r=row: _place_crud.add_link(s, r)],
|
||||
)
|
||||
if err == ErrorType.SUCCESS:
|
||||
@@ -231,7 +231,7 @@ async def confirm_targets(place, place_id: str, only_link_ids: list[str] | None)
|
||||
"""
|
||||
stat = {"confirmed": 0, "already": 0, "unsupported": 0}
|
||||
err, links = await DB_SESSION_MNG.execute_lambda(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
DBWRType.DB_READ.value,
|
||||
lambda s: _place_crud.list_links(s, uuid.UUID(place_id), False),
|
||||
)
|
||||
@@ -253,7 +253,7 @@ async def confirm_targets(place, place_id: str, only_link_ids: list[str] | None)
|
||||
targets.append(link)
|
||||
continue
|
||||
_e, rowcount = await DB_SESSION_MNG.execute_lambda_claim(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
lambda s, l=link: _place_crud.confirm_link(s, uuid.UUID(place_id), l.link_id, place.verified_by, now),
|
||||
)
|
||||
if rowcount:
|
||||
@@ -322,7 +322,7 @@ async def ensure_units(place_id: str, sources: list) -> dict:
|
||||
return {}
|
||||
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(
|
||||
units.DBType(),
|
||||
place_units.DBType(),
|
||||
DBWRType.DB_READ.value,
|
||||
lambda s: _place_crud.list_units(s, uuid.UUID(place_id)),
|
||||
)
|
||||
@@ -332,9 +332,9 @@ async def ensure_units(place_id: str, sources: list) -> dict:
|
||||
for order, name in enumerate(names):
|
||||
if name in existing:
|
||||
continue
|
||||
row = units(place_id=uuid.UUID(place_id), name=name, sort_order=order)
|
||||
row = place_units(place_id=uuid.UUID(place_id), name=name, sort_order=order)
|
||||
run_err = await DB_SESSION_MNG.execute_lambda_run(
|
||||
[units.DBType()],
|
||||
[place_units.DBType()],
|
||||
[lambda s, r=row: _place_crud.add_unit(s, r)],
|
||||
)
|
||||
if run_err == ErrorType.SUCCESS:
|
||||
@@ -356,7 +356,7 @@ async def store_facts(user_info, place_id: str, sources: list, unit_map: dict) -
|
||||
stat = {"stored": 0, "refreshed": 0, "candidate": 0, "rejected": 0, "by_reason": {}}
|
||||
|
||||
for source in sources:
|
||||
for cf in source.place_facts:
|
||||
for cf in source.facts:
|
||||
unit_id = unit_map.get(cf.unit_name) if cf.scope == "unit" else None
|
||||
if cf.scope == "unit" and unit_id is None:
|
||||
stat["rejected"] += 1
|
||||
@@ -391,10 +391,10 @@ async def store_media(place_id: str, sources: list, unit_map: dict) -> dict:
|
||||
from sqlalchemy import select
|
||||
|
||||
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(media).where(media.place_id == uuid.UUID(place_id), media.deleted == False) # noqa: E712
|
||||
s, select(place_photos).where(place_photos.place_id == uuid.UUID(place_id), place_photos.deleted == False) # noqa: E712
|
||||
),
|
||||
)
|
||||
seen = {r.origin_url for r in (rows or []) if r.origin_url} if err == ErrorType.SUCCESS else set()
|
||||
@@ -405,7 +405,7 @@ async def store_media(place_id: str, sources: list, unit_map: dict) -> dict:
|
||||
if cm.origin_url in seen:
|
||||
stat["skipped_duplicate"] += 1
|
||||
continue
|
||||
row = media(
|
||||
row = place_photos(
|
||||
place_id=uuid.UUID(place_id),
|
||||
unit_id=unit_map.get(cm.unit_name),
|
||||
url=cm.origin_url, # Vision·재게시 결론 전까지는 원본 URL 을 그대로 둔다
|
||||
@@ -417,7 +417,7 @@ async def store_media(place_id: str, sources: list, unit_map: dict) -> dict:
|
||||
sort_order=order,
|
||||
)
|
||||
run_err = await DB_SESSION_MNG.execute_lambda_run(
|
||||
[media.DBType()],
|
||||
[place_photos.DBType()],
|
||||
[lambda s, r=row: DB_SESSION_MNG.insert(s, r, raise_error=False)],
|
||||
)
|
||||
if run_err == ErrorType.SUCCESS:
|
||||
@@ -515,7 +515,7 @@ async def run_collect(job: dict) -> dict:
|
||||
# intro 같은 allow_llm 필드에 원문을 넣으면 발행본이 원문으로 덮인다(2026-08-31 사고).
|
||||
if (source.text or "").strip():
|
||||
await DB_SESSION_MNG.execute_lambda_claim(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
lambda sess, u=link.url, t=source.text: _place_crud.set_link_raw(
|
||||
sess, uuid.UUID(place_id), u, {"text": t[:8000]},
|
||||
),
|
||||
@@ -584,7 +584,7 @@ async def _store_booking_link(place, place_id: str, source) -> bool:
|
||||
f"{place.name} 네이버 예약", SourceType.CRAWL,
|
||||
)
|
||||
await DB_SESSION_MNG.execute_lambda_claim(
|
||||
place_links.DBType(),
|
||||
place_channels.DBType(),
|
||||
lambda s: _place_crud.confirm_link_by_url(s, uuid.UUID(place_id), url, place.verified_by, GTime.UTC()),
|
||||
)
|
||||
LOG.i(f"[collect] 네이버 예약 링크 {'등록·확정' if added else '확정'} — {url}")
|
||||
|
||||
Reference in new issue
Block a user