[feat] solution: 지역 이야기 생성 · 발행본 섹션 손질 · 마이그레이션 주석 축약
- 지역 이야기(가요·인물·연표·엽서·퀴즈) 생성 경로: story_service · grounding/story · section_prompts. 지금까지 만들 자리가 없어 시안에만 손으로 넣은 3만 자였다 - 발행본 섹션: ItinerarySection · Carousel 레일 자동재생(use-rail-autoplay) · Festival · LocalGuide · Weather · Gallery · Header/Footer - 목업 payload 를 payloads-mockup/ 으로 분리 — 발행 대상과 섞이지 않게 - DB 새 구조 후속: site_payload · local_content_crud 조인 정리 · 테스트 - 마이그레이션 주석 축약: 9개 파일 합계 주석 비율 48% → 25%. 실측과 밟은 함정만 남기고 논증은 커밋 메시지로 옮겼다 검증: site·frontend 빌드 통과 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3910feddfb
commit
328d9e18ee
58 files changed
+5625
-412
No files matched your search
@@ -127,13 +127,25 @@ async def generate_region_stories(region_code: str, region_label: str, kinds: li
|
||||
return {"region_code": region_code, "counts": result, "notes": notes}
|
||||
|
||||
|
||||
async def has_stories(region_code: str) -> bool:
|
||||
"""이 지역에 이미 이야기가 있나. cache-aside 판단용 — 한 건이라도 있으면 다시 부르지 않는다."""
|
||||
async def missing_kinds(region_code: str) -> list[str]:
|
||||
"""이 지역에 아직 없는 이야기 종류. cache-aside 판단용.
|
||||
|
||||
★ 예전엔 `has_stories` 하나였다 — **한 건이라도 있으면** 다시 부르지 않았다.
|
||||
그 가드는 "같은 지역 두 번째 숙소"만 생각한 것이라, **종류가 늘어난 날** 정확히 반대로
|
||||
동작한다: 이미 다섯이 들어 있는 지역은 여섯 번째(`daily`)를 영영 못 받는다.
|
||||
새 지역에서만 여섯이 채워지고 기존 지역은 다섯에 멈춰, 같은 템플릿을 골라도 지역에
|
||||
따라 탭 수가 다른 상태가 된다(실측 2026-09-10, 52군산시).
|
||||
★ 요금 가드는 그대로다 — 없는 종류만 부른다. 이미 있는 종류는 여전히 한 번도 다시 안 부른다.
|
||||
"""
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(
|
||||
area_contents.DBType(), DBWRType.DB_READ.value,
|
||||
lambda s: crud_list(s, region_code),
|
||||
)
|
||||
return err == ErrorType.SUCCESS and bool(rows)
|
||||
if err != ErrorType.SUCCESS:
|
||||
# 읽지 못했으면 "없다"고 단정하지 않는다 — 모르는 상태로 유료 호출을 걸지 않는다.
|
||||
return []
|
||||
have = {str(getattr(row, "kind", "") or "") for row in rows}
|
||||
return [kind for kind in prompts.kinds() if kind not in have]
|
||||
|
||||
|
||||
async def crud_list(session, region_code: str):
|
||||
@@ -185,12 +197,14 @@ async def run_local_sync(job: dict) -> dict:
|
||||
if not perplexity.is_configured():
|
||||
out["stories"] = {"skipped": "PERPLEXITY_API_KEY 미설정"}
|
||||
return out
|
||||
if await has_stories(region_code):
|
||||
# ★ 같은 지역 두 번째 숙소다. 다시 부르면 같은 답에 요금만 두 번 낸다.
|
||||
# ★ 잡이 종류를 지정했으면 그대로 따른다(재생성·보정용). 아니면 **없는 것만** 채운다 —
|
||||
# 같은 지역 두 번째 숙소는 부를 것이 없어 곧바로 빠져나간다.
|
||||
wanted = payload.get("kinds") or await missing_kinds(region_code)
|
||||
if not wanted:
|
||||
out["stories"] = {"skipped": "이미 있다"}
|
||||
return out
|
||||
|
||||
out["stories"] = await generate_region_stories(region_code, region_label, payload.get("kinds"))
|
||||
out["stories"] = await generate_region_stories(region_code, region_label, wanted)
|
||||
return out
|
||||
|
||||
|
||||
@@ -213,7 +227,7 @@ async def enqueue_region_job(place) -> str | None:
|
||||
"""업장의 지역 데이터 잡을 큐에 넣고 job_id 를 돌려준다. 지역을 모르면 넣지 않는다.
|
||||
|
||||
★ dedupe 는 **업장 단위**다(`local:{place_id}`). 반경 수집이 업장마다 필요해서다 —
|
||||
지역 이야기의 중복 호출은 잡 안의 `has_stories` 가드가 막는다.
|
||||
지역 이야기의 중복 호출은 잡 안의 `missing_kinds` 가드가 막는다.
|
||||
★ 부르는 곳이 둘이다: 수집 완료 직후(collect_service)와 위저드의 생성 단계(place_service).
|
||||
먼저 넣은 잡이 아직 살아 있으면 enqueue_job 이 그 id 를 돌려준다 — 위저드는 그걸 기다린다.
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user