[feat] solution/backend: 일정을 스냅샷에서 읽는다 — 즉석 계산을 잠시 쉬게 한다
This commit is contained in:
1 parent
2824701030
commit
8dba691274
3 files changed
+94
-13
No files matched your search
@@ -31,7 +31,6 @@ from common.enums import (
|
||||
SourceType,
|
||||
)
|
||||
from common.logger import LOG
|
||||
from services.itinerary import build_itineraries
|
||||
|
||||
# 렌더러가 확인하는 스키마 버전. 모양이 바뀌면 여기와 site-payload.ts 를 같이 올린다.
|
||||
SCHEMA_VERSION = 1
|
||||
@@ -649,15 +648,17 @@ def _local(snapshot_local: dict, base_lat: float | None, base_lng: float | None)
|
||||
fact·사진과 같은 분업이다.
|
||||
★ 예전에는 이 자리가 무조건 빈 배열이었다. local_contents 에 검수·발행된 지역 정보가 있어도
|
||||
payload 경계에서 통째로 버려져, 모든 발행 사이트의 지역 정보 섹션이 영구히 안 나왔다.
|
||||
★ itineraries(1박2일·2박3일 일정)는 저장하지 않고 여기서 즉석 계산한다 —
|
||||
재료가 갱신되면 다음 빌드에서 일정도 저절로 최신이 된다(services/itinerary.py).
|
||||
렌더러에 아직 이 필드의 자리가 없다 — 모르는 필드는 무시되므로 화면은 변하지 않는다."""
|
||||
★ itineraries(1박2일·2박3일 각 5개)는 **스냅샷에서 읽는다.** 예전에는 이 자리에서
|
||||
거리 기반으로 즉석 계산했다(services/itinerary.py) — 거리 계산은 공짜라 그게 맞았다.
|
||||
LLM 생성으로 바뀌면서 건당 20~50초·유료가 되어 표에 저장하고 그걸 읽는다
|
||||
(services/itinerary_llm_service · tmp/superpowers/specs/2026-09-11-llm-itinerary-design.md).
|
||||
★ 여기서 DB 를 읽지 않는다. 읽는 곳은 services/snapshot._local_contents 하나다 —
|
||||
이 함수가 순수해야 "스냅샷과 다른 페이지"가 생기지 않는다(파일 상단 원칙).
|
||||
★ services/itinerary.py 는 지우지 않았다. 고도화해서 되살릴 때 이 블록을 되돌린다."""
|
||||
contents = (snapshot_local or {}).get("contents") or []
|
||||
# courses(여행코스)는 백엔드만 채운다 — 렌더러 타입에 아직 자리가 없어 화면은 무시한다(2026-09-07).
|
||||
local = {"attractions": [], "restaurants": [], "festivals": [], "courses": []}
|
||||
synced_at = None
|
||||
# 일정 계산용 원본 행(좌표가 body 에 있다). payload 항목은 좌표를 싣지 않으므로 따로 모은다.
|
||||
raw = {"attractions": [], "restaurants": [], "festivals": []}
|
||||
|
||||
for row in contents:
|
||||
if not isinstance(row, dict):
|
||||
@@ -678,17 +679,14 @@ def _local(snapshot_local: dict, base_lat: float | None, base_lng: float | None)
|
||||
entry = _festival(row)
|
||||
if entry:
|
||||
local["festivals"].append(entry)
|
||||
raw["festivals"].append(row)
|
||||
elif content_type == LocalContentType.ATTRACTION.value:
|
||||
entry = _local_place(row, "관광지")
|
||||
if entry:
|
||||
local["attractions"].append(entry)
|
||||
raw["attractions"].append(row)
|
||||
elif content_type == LocalContentType.RESTAURANT.value:
|
||||
entry = _local_place(row, "맛집")
|
||||
if entry:
|
||||
local["restaurants"].append(entry)
|
||||
raw["restaurants"].append(row)
|
||||
elif content_type == LocalContentType.COURSE.value:
|
||||
entry = _local_place(row, "여행코스")
|
||||
if entry:
|
||||
@@ -704,9 +702,10 @@ def _local(snapshot_local: dict, base_lat: float | None, base_lng: float | None)
|
||||
local.setdefault("story", {})[kind] = [i for i in items if isinstance(i, dict)]
|
||||
# 그 밖의 content_type 은 버린다 — 렌더러 타입에 담을 자리가 없다.
|
||||
|
||||
itineraries = build_itineraries(
|
||||
base_lat, base_lng, raw["attractions"], raw["restaurants"], raw["festivals"]
|
||||
)
|
||||
itineraries = [
|
||||
course for course in ((snapshot_local or {}).get("itineraries") or [])
|
||||
if isinstance(course, dict)
|
||||
]
|
||||
if itineraries:
|
||||
local["itineraries"] = itineraries
|
||||
|
||||
|
||||
@@ -273,7 +273,20 @@ async def _local_contents(place) -> dict:
|
||||
[_Row(r, b) for r, b, _ in merged], seen, source=LocalSource.TOUR_API.value
|
||||
)
|
||||
|
||||
return {"region_code": region_code or None, "contents": contents}
|
||||
# ── 여행 일정(place_itineraries) — 업장마다 기간당 한 행 ──────────
|
||||
# ★ 여기서 **읽기만** 한다. 생성은 잡·빌드가 한다(services/itinerary_llm_service).
|
||||
# 스냅샷 조립 안에서 LLM 을 부르면 발행 한 번이 1분 늘고, 캔버스 조회도 같은 길을 탄다.
|
||||
itineraries: list[dict] = []
|
||||
if place_id is not None:
|
||||
from services.itinerary_llm_service import get_itineraries
|
||||
|
||||
itineraries = await get_itineraries(place_id)
|
||||
|
||||
return {
|
||||
"region_code": region_code or None,
|
||||
"contents": contents,
|
||||
"itineraries": itineraries,
|
||||
}
|
||||
|
||||
|
||||
class _Row:
|
||||
|
||||
Reference in new issue
Block a user