feat(supporters): 회복 일정 플래너에 한국관광공사 TourAPI 데이터 합침 + 옛 주소 리다이렉트 + 404 페이지

- src/lib/tour.ts: 사전 수집 JSON(medicalTourismKo/medicalTourism)을 추천 후보로 변환. 관광지·문화시설→관광, 쇼핑, 음식점(일반식 단계에서만), 숙박→숙소. 사우나·스파는 회복기 금지라 제외. 거리로 외출 등급(600m·3km)
- 큐레이션(places.json) 1순위, TourAPI 2순위 가점. 타임라인 추천에 이동 시간 라벨과 '관광공사' 표시
- 체류 기간과 겹치는 행사 섹션(가까운 순 6곳, 자유 외출 단계 도달일 표시), 자유 외출(L3) 날에 행사 1건 추가
- 숙소 그리드에 TourAPI 숙박 가까운 순 6곳 추가(예약 검색은 영문 이름으로)
- scripts/fetch_medical_tourism.py: Productize 브랜치의 수집 스크립트 가져옴(화면 경로 주석 갱신)
- vercel.json: /recovery·/stay·/en/recovery·/en/stay → /plan·/en/plan 영구 리다이렉트. src/pages/404.astro 사이트 스타일 404
- 테스트 14건(어댑터·우선순위·유동식 제외·축제)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Fable 5.1 committed 2026-09-11 11:01:32 +09:00
1 parent f9e91d3305
commit 83b8343262
11 files changed
+6982 -21

No files matched your search

+8 -4
View File
@@ -16,11 +16,13 @@ export interface Procedure {
export interface Place {
id: string; name: L10n; category: string; minLevel: number; dietOk?: string[]; distanceKm: number; indoor: boolean;
area: L10n; note: L10n; mapQuery: string | null; bookingQuery?: string; verify: boolean;
source?: 'curated' | 'tourapi'; travelLabel?: string; image?: string; url?: string;
}
export interface Nationality { code: string; label: L10n; visaFreeDays: number | null; longHaul: boolean }
export interface PlanInput { procedure: Procedure; surgeryDate: string; nationality?: Nationality | null; prefs: string[] }
export interface PlanDay { date: string; offset: number; level: number; diet: DietStep['type']; picks: Place[]; isSurgery: boolean; isHospital: boolean; isStitch: boolean; isArrival: boolean; isDeparture: boolean }
export interface PlanFestival { id: string; title: string; start: string; end: string }
export interface PlanInput { procedure: Procedure; surgeryDate: string; nationality?: Nationality | null; prefs: string[]; festivals?: PlanFestival[] }
export interface PlanDay { date: string; offset: number; level: number; diet: DietStep['type']; picks: Place[]; festivals: PlanFestival[]; isSurgery: boolean; isHospital: boolean; isStitch: boolean; isArrival: boolean; isDeparture: boolean }
export interface Plan {
arriveBy: string; surgeryDate: string; dischargeDate: string | null; stitchDate: string | null; earliestDeparture: string | null;
stayNights: number | null; preOpDays: number; days: PlanDay[];
@@ -57,6 +59,7 @@ export function scorePlace(place: Place, level: number, diet: DietStep['type'],
if (place.category === 'food' && place.dietOk && !place.dietOk.includes(diet)) return -1;
let s = 0;
if (prefs.length === 0 || prefs.includes(place.category)) s += 3;
if (place.source !== 'tourapi') s += 0.75; // 큐레이션(1순위)이 같은 조건이면 먼저 나온다
if (place.category === 'essentials' || place.category === 'care') s += 1; // 회복에 직접 필요한 것은 기본 가점
s += 2 - Math.min(2, level - place.minLevel); // 오늘 등급에 맞는 곳을 우선
s += Math.max(0, 1.5 - place.distanceKm / 4); // 가까울수록 가점(최대 1.5)
@@ -74,7 +77,7 @@ export function pickForDay(places: Place[], level: number, diet: DietStep['type'
}
export function buildPlan(input: PlanInput, places: Place[]): Plan {
const { procedure: p, surgeryDate, nationality, prefs } = input;
const { procedure: p, surgeryDate, nationality, prefs, festivals = [] } = input;
const preOp = effectivePreOpDays(p, nationality);
const arriveBy = addDays(surgeryDate, -preOp);
const nights = p.hospitalNights.value;
@@ -94,7 +97,8 @@ export function buildPlan(input: PlanInput, places: Place[]): Plan {
const recentSet = new Set(recent.slice(-6));
const picks = level === 0 || off === 0 ? [] : pickForDay(places, level, diet, prefs, recentSet);
recent.push(...picks.map((x) => x.id));
days.push({ date, offset: off, level, diet, picks, isSurgery: off === 0, isHospital, isStitch: stitchDate === date, isArrival: off === -preOp, isDeparture: earliestDeparture === date });
const dayFest = level >= 3 ? festivals.filter((f) => f.start <= date && f.end >= date).slice(0, 1) : []; // 행사는 자유 외출(L3) 날에만
days.push({ date, offset: off, level, diet, picks, festivals: dayFest, isSurgery: off === 0, isHospital, isStitch: stitchDate === date, isArrival: off === -preOp, isDeparture: earliestDeparture === date });
}
return { arriveBy, surgeryDate, dischargeDate, stitchDate, earliestDeparture, stayNights: dep === null ? null : preOp + dep, preOpDays: preOp, days };
}
+89
View File
@@ -0,0 +1,89 @@
// 한국관광공사 TourAPI 사전 수집 데이터(src/data/medicalTourism*.json)를 회복 일정 플래너의 장소·축제 후보로 바꾼다 (설계 v0.2 §13.5, 2순위 소스).
// 수집은 scripts/fetch_medical_tourism.py 가 병원 좌표 기준으로 미리 해 두고, 화면은 이 파일의 결과만 쓴다. 외부 호출 없음.
// 식이 적합성은 TourAPI 가 주지 않으므로 판정하지 않는다: 음식점은 일반식 단계에서만 후보가 되고, 죽·스무디 같은 회복 초기 식사는 큐레이션(places.json)이 맡는다.
import type { Place, L10n } from './plan';
export interface TourItem {
id: string; title: string; address: string; image: string | null; tel: string | null; lat: number; lng: number;
distanceM: number; travel: { mode: string; minutes: number; label: string } | null; overview: string; homepage: string;
startDate?: string; endDate?: string; season?: string;
}
export interface TourData {
places: Record<string, TourItem[]>;
festivals: TourItem[];
meta: { lang?: string; source: string; fetchedAt: string; origin?: { lat: number; lng: number; label: string } };
}
/** TourAPI 유형 → 플래너 카테고리. wellness(사우나·스파)는 회복기 금지 항목이라 후보에서 뺀다. */
const CATEGORY: Record<string, string | null> = { attraction: 'sightseeing', culture: 'sightseeing', shopping: 'shopping', restaurant: 'food', stay: 'hotel', wellness: null };
/** 거리로 외출 등급을 정한다: 600m 안 근거리(L1), 3km 안 반나절(L2), 그 밖은 자유 외출(L3). */
export const levelByDistance = (m: number): number => (m <= 600 ? 1 : m <= 3000 ? 2 : 3);
const both = (s: string): L10n => ({ ko: s, en: s });
/** 주소를 짧은 동네 표기로. 국문은 '구 도로명', 영문은 첫 쉼표 앞 도로명. */
const areaLabel = (address: string, lang: 'ko' | 'en'): string => {
const a = (address || '').trim();
if (lang === 'en') return a.split(',').map((x) => x.trim()).filter((x) => x && !/^\d+$/.test(x))[0] ?? a;
return a.replace(/^서울특별시\s*/, '').split(/\s+/).slice(0, 2).join(' ');
};
const firstSentence = (s: string, n = 140): string => {
const t = (s || '').replace(/\d+\s*m?\s*NAVER\s*©\s*NAVER Corp\.?/gi, '').replace(/\s+/g, ' ').trim();
if (t.length <= n) return t;
const cut = t.slice(0, n);
const stop = Math.max(cut.lastIndexOf('. '), cut.lastIndexOf('다. '), cut.lastIndexOf('。'));
return (stop > 40 ? cut.slice(0, stop + 1) : cut).trim() + (stop > 40 ? '' : '…');
};
/** "K-그랜드 호스텔 강남 1(K-GRAND HOSTEL GANGNAM1)" → 예약 검색용 영문 이름이 괄호 안에 있으면 그것을 쓴다. */
export const bookingName = (title: string): string => {
const m = title.match(/\(([^)]*[A-Za-z][^)]*)\)\s*$/);
return (m ? m[1] : title).trim();
};
export function tourToPlaces(data: TourData, lang: 'ko' | 'en'): Place[] {
const out: Place[] = [];
for (const [type, items] of Object.entries(data.places ?? {})) {
const category = CATEGORY[type];
if (!category) continue;
for (const it of items) {
if (!it.lat || !it.lng) continue;
const km = Math.round((it.distanceM / 1000) * 10) / 10;
out.push({
id: `tour-${type}-${it.id}`,
name: both(it.title),
category,
minLevel: category === 'hotel' ? 0 : levelByDistance(it.distanceM),
dietOk: category === 'food' ? ['normal'] : undefined,
distanceKm: km,
indoor: type === 'shopping' || type === 'culture' || type === 'restaurant' || type === 'stay',
area: both(areaLabel(it.address, lang)),
note: both(firstSentence(it.overview)),
mapQuery: it.title,
bookingQuery: category === 'hotel' ? bookingName(it.title) : undefined,
verify: true,
source: 'tourapi',
travelLabel: it.travel?.label ?? undefined,
image: it.image ?? undefined,
url: it.homepage || undefined,
});
}
}
return out;
}
export interface Festival { id: string; title: string; start: string; end: string; distanceKm: number; travelLabel?: string; blurb: string; image?: string; url?: string; address: string }
const iso = (d?: string) => (d && d.length === 8 ? `${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6, 8)}` : '');
/** 체류 기간 [from, to] 와 겹치는 행사만, 가까운 순. */
export function festivalsDuring(data: TourData, from: string, to: string, max = 6): Festival[] {
return (data.festivals ?? [])
.map((f) => ({ f, start: iso(f.startDate), end: iso(f.endDate) }))
.filter((x) => x.start && x.end && x.start <= to && x.end >= from)
.sort((a, b) => a.f.distanceM - b.f.distanceM)
.slice(0, max)
.map(({ f, start, end }) => ({
id: `fest-${f.id}`, title: f.title, start, end, distanceKm: Math.round((f.distanceM / 1000) * 10) / 10,
travelLabel: f.travel?.label ?? undefined, blurb: firstSentence(f.overview), image: f.image ?? undefined,
url: f.homepage || undefined, address: f.address,
}));
}