feat: 축제·전시·콘서트·팝업 7일마다 수집, 피드 행사 종류 섞기

- 행사 수집을 화면 요청에서 빼고 worker 가 월 04:00(켤 때 7일 기록 없으면 한 번) 전국 17개 시도를 받는다
- 문화정보원 음악/콘서트(B000) 추가, 쪽·시도 사이 1초 간격으로 초당 요청 제한 회피
- 팝가(popga.co.kr) 팝업스토어 수집: 사이트맵 + 상세 JSON-LD, 바뀐 페이지만 다시 읽음
- 수집이 끝나면 Teams Workflows webhook 으로 종류별 건수 알림 (TEAMS_WEBHOOK_URL)
- event.kind(1=축제 2=전시 3=콘서트 4=팝업) 칸과 종류별 아이콘 추가
- 피드 행사 카드·띠를 축제→팝업→전시→콘서트 차례로 섞음
- 포스트 종류별 내용·피드 기획 문서 갱신

같은 작업 폴더의 다른 작업(외부 API 가드, 노을·달 계산, 각 API, 문서 파일 이름 정리 등)도 함께 담김.
This commit is contained in:
minaChoi committed 2026-10-07 12:03:48 +09:00
1 parent b61ed92c54
commit 997a366e76
70 files changed
+2083 -649

No files matched your search

+65 -159
View File
@@ -1,72 +1,11 @@
import { useQuery } from '@tanstack/react-query'
import type { ReactNode } from 'react'
import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen'
import type { BestTime, RegionData, SkyPlanData, SpotData } from '../api/client/types.gen'
import type { BestTime, SkyPlanData } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { clockShort, compass, dayLabel, loadOf } from './lib'
import { clockShort, loadOf } from './lib'
import { useRegion } from './regionContext'
import { Sec, Skel, StateBox } from './ui'
const W = 400
const H = 260
const BLOCKS = [
[20, 20, 90, 60],
[130, 18, 100, 52],
[262, 22, 110, 48],
[24, 190, 110, 54],
[170, 196, 90, 50],
[290, 180, 92, 62],
]
/** 내 구 중심을 기준으로 명소를 km 단위로 놓고, 해 지는 방향을 그린다 */
function SpotMap({ region, spots, azimuth }: { region: RegionData; spots: SpotData[]; azimuth: number | null | undefined }) {
const kx = 111 * Math.cos((region.lat * Math.PI) / 180)
const pts = spots.map((s) => ({ no: s.no, x: (s.lon - region.lon) * kx, y: (s.lat - region.lat) * 111 }))
const maxX = Math.max(0.5, ...pts.map((p) => Math.abs(p.x)))
const maxY = Math.max(0.5, ...pts.map((p) => Math.abs(p.y)))
const scale = Math.min(160 / maxX, 95 / maxY)
const cx0 = W / 2
const cy0 = H / 2
const az = ((azimuth ?? 270) * Math.PI) / 180
const dir = (len: number, turn = 0) => [cx0 + Math.sin(az + turn) * len, cy0 - Math.cos(az + turn) * len] as const
const tip = dir(190)
const label = dir(120)
return (
<div className="mx-3 mt-3 overflow-hidden rounded-[26px] bg-[#eef2e8] shadow-[inset_0_0_0_2px_#e1e7da]">
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${region.name} 주변 노을 명소 지도`} className="block h-auto w-full">
<rect width={W} height={H} fill="#eef2e8" />
{BLOCKS.map(([x, y, w, h]) => (
<rect key={`${x}-${y}`} x={x} y={y} width={w} height={h} rx="10" fill="#e1e7da" />
))}
<path d={`M${W / 2 - 10} 0 L${W / 2 + 4} ${H}`} stroke="#fff" strokeWidth="9" />
<path d={`M0 ${H / 2 - 30} H${W}`} stroke="#fff" strokeWidth="10" />
{azimuth != null && (
<>
<path d={`M${cx0} ${cy0} L${dir(260, -0.3).join(' ')} L${dir(260, 0.3).join(' ')} Z`} fill="#ff8e4e" opacity=".18" />
<path d={`M${cx0} ${cy0} L${tip.join(' ')}`} stroke="#ff7a45" strokeWidth="3" strokeDasharray="7 6" />
<text x={Math.min(W - 110, Math.max(8, label[0] - 50))} y={label[1] + 26} fontFamily="Jua,sans-serif" fontSize="14" fill="#d4552a">
해 지는 {compass(azimuth)}쪽
</text>
</>
)}
<circle cx={cx0} cy={cy0} r="13" fill="#4f97e3" opacity=".25" />
<circle cx={cx0} cy={cy0} r="6" fill="#4f97e3" stroke="#fff" strokeWidth="2" />
<text x={cx0 + 14} y={cy0 + 18} fontFamily="Pretendard Variable,sans-serif" fontWeight="800" fontSize="11" fill="#2f6fb7">
지금 여기
</text>
{pts.map((p) => (
<g key={p.no}>
<circle cx={cx0 + p.x * scale} cy={cy0 - p.y * scale} r="13" fill="#ff7a45" stroke="#fff" strokeWidth="3" />
<text x={cx0 + p.x * scale} y={cy0 - p.y * scale + 5} textAnchor="middle" fontFamily="Bagel Fat One,sans-serif" fontSize="14" fill="#fff">
{p.no}
</text>
</g>
))}
</svg>
</div>
)
}
import { MapLink, Sec, Skel, StateBox } from './ui'
function LiSkel({ ghost = false }: { ghost?: boolean }) {
return (
@@ -89,54 +28,58 @@ function LiSkel({ ghost = false }: { ghost?: boolean }) {
)
}
const HERO = 'relative mx-3 mt-1 min-h-[350px] overflow-hidden rounded-[32px] bg-[linear-gradient(180deg,#7e6fe6,#f08aa2_58%,#ffc28a)] px-5 pt-5 pb-16 text-white'
// 다른 탭 히어로보다 짧게. 배경은 하늘 상황별 색(b-sit-1~5), 아래에 동네 실루엣
const HERO = 'relative mx-3 mt-1 min-h-[230px] overflow-hidden rounded-[32px] px-5 pt-5 pb-14 text-white'
const THREE = [0, 1, 2]
const FOUR = [0, 1, 2, 3]
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
/** 결론 → 왜 → 몇 시에 어디로 → 점수(보조). 글자 줄 수를 고정해 스켈레톤과 크기가 같다 */
function HeroBody({ plan }: { plan?: SkyPlanData }) {
/** 히어로엔 해 지는 시각과 하늘 상황 한 줄만. 결론·이유는 아래 카드로 */
function HeroBody({ plan, sunset }: { plan?: SkyPlanData; sunset?: string }) {
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
const place = plan && (plan.spot ? `${plan.spot.name} · ${plan.spot.distance_km}km` : plan.verdict === 'rest' ? '오늘은 나가지 않아도 돼요' : '30km 안에 등록된 명소가 없어요')
return (
<div aria-hidden={plan ? undefined : true}>
<p className="relative m-0 mt-1.5 font-jua text-[38px] leading-[1.1]">{v(plan?.headline, 'w-[200px]')}</p>
<div className="relative z-[1] mt-3 rounded-[20px] bg-[rgb(45_36_64/0.55)] px-4 py-3">
<p className="m-0 line-clamp-2 h-[2lh] text-[14.5px] leading-snug font-bold">{v(plan?.reason, 'w-[250px]')}</p>
<div className="mt-2.5 grid grid-cols-[auto_1fr] items-center gap-x-3 border-t border-white/25 pt-2.5">
<b className="row-span-2 font-bagel text-[30px] leading-none font-normal">{v(plan?.best_at && clockShort(plan.best_at), 'w-[76px]')}</b>
<span className="text-[13px] font-extrabold">{v(plan && '가장 붉을 때', 'w-20')}</span>
<span className="truncate text-[13px] font-bold">{v(place, 'w-36')}</span>
</div>
<p className="m-0 mt-2.5 border-t border-white/25 pt-2 text-[12.5px] leading-snug font-bold">
{v(plan && `노을 점수 ${plan.score}점 · ${plan.grade_label}`, 'w-32')}
<small className="block text-[12px] font-semibold">{v(plan && '해 지는 쪽 구름 높이·양으로 매겨요. 60점부터 나가 볼 만해요', 'w-56')}</small>
</p>
</div>
<div className="relative z-[1] [text-shadow:0_2px_10px_rgb(50_25_70/0.35)]" aria-hidden={plan ? undefined : true}>
<p className="m-0 mt-2.5 font-bagel text-[52px] leading-none">{v(sunset && clockShort(sunset), 'w-[150px]')}</p>
<p className="m-0 mt-1.5 font-jua text-[21px]">{v(plan?.situation_label ?? plan?.headline, 'w-[190px]')}</p>
</div>
)
}
/** 일몰 전 골든아워 → 해 짐 → 가장 붉을 때 → 블루아워, 한 줄 */
/** 결론과 이유, 예보 모델이 얼마나 같은 예보를 냈는지, 점수(작게) */
function Verdict({ plan }: { plan?: SkyPlanData }) {
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
const agree = plan?.models_total ? `예보 모델 ${plan.models_total}개 중 ${plan.models_agree}개가 같은 예보` : ''
return (
<div className="mx-3 mt-3 rounded-[22px] bg-white px-4 py-3 text-[14px] font-semibold shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={plan ? undefined : true}>
<p className="m-0">
<b className="mr-1.5 font-jua text-[17px] font-normal">{v(plan?.headline, 'w-20')}</b>
{v(plan?.reason, 'w-[220px]')}
</p>
<small className="mt-1 block text-[12px] font-bold text-(--ink2)">{v(plan && [agree, `노을 점수 ${plan.score}`].filter(Boolean).join(' · '), 'w-48')}</small>
</div>
)
}
/** 골든아워 → 해 짐 → 블루아워 */
function Timeline({ rows }: { rows?: BestTime[] }) {
return (
<ol className="relative mx-3 mt-3 grid grid-cols-4 rounded-[22px] bg-white px-2 pt-4 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
<span className="absolute inset-x-[12.5%] top-[22px] h-0.5 bg-(--line)" aria-hidden="true" />
{(rows ?? FOUR.map(() => undefined)).map((t, i) => (
<li key={t?.kind ?? i} className="relative flex flex-col items-center text-center">
<span className={cx('size-3 rounded-full border-2 border-(--line) bg-white', t?.kind === 'peak' && 'border-[#d6457a] bg-[#d6457a]')} />
<b className={cx('mt-1.5 font-bagel text-lg leading-tight font-normal', t?.kind === 'peak' && 'text-[#d6457a]')}>{t ? clockShort(t.at) : <Skel className="w-12" />}</b>
<span className="text-[12px] font-bold text-(--ink2)">{t ? t.label : <Skel className="w-11" />}</span>
</li>
))}
</ol>
<div className="mx-3 mt-3 rounded-[22px] bg-white px-2 pt-4 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
<ol className="relative grid grid-cols-3">
<span className="absolute inset-x-[16.6%] top-[6px] h-0.5 bg-(--line)" aria-hidden="true" />
{(rows ?? THREE.map(() => undefined)).map((t, i) => (
<li key={t?.kind ?? i} className="relative flex flex-col items-center text-center">
<span className={cx('size-3 rounded-full border-2 border-(--line) bg-white', t?.kind === 'sun' && 'border-(--orange) bg-(--orange)')} />
<b className="mt-1.5 font-bagel text-lg leading-tight font-normal">{t ? clockShort(t.at) : <Skel className="w-12" />}</b>
<span className="text-[12px] font-bold text-(--ink2)">{t ? t.label : <Skel className="w-11" />}</span>
</li>
))}
</ol>
</div>
)
}
function SpotsSkel() {
return (
<>
<Skel shape className="mx-3 mt-3 aspect-[400/260] rounded-[26px]" />
<ul className="mx-3 mt-1.5 flex flex-col">
{THREE.map((i) => (
<LiSkel key={i} />
@@ -146,26 +89,6 @@ function SpotsSkel() {
)
}
function DaysSkel() {
return (
<div className="grid grid-cols-3 gap-2 p-3" aria-hidden="true">
{THREE.map((i) => (
<div key={i} className="rounded-[20px] bg-white p-3 text-center shadow-[inset_0_-5px_0_var(--shade)]">
<small className="block text-[12.5px] font-extrabold">
<Skel className="w-10" />
</small>
<b className="block font-bagel text-[30px] font-normal">
<Skel className="w-10" />
</b>
<span className="block text-xs font-bold">
<Skel className="w-12" />
</span>
</div>
))}
</div>
)
}
function RankSkel() {
return (
<ul className="mx-3 mt-1.5 flex flex-col" aria-hidden="true">
@@ -176,13 +99,13 @@ function RankSkel() {
)
}
function Li({ no, title, sub, right, mine = false }: { no: number; title: string; sub?: string | null; right: string; mine?: boolean }) {
function Li({ no, title, sub, right, mine = false, place }: { no: number; title: string; sub?: string | null; right: string; mine?: boolean; place?: string }) {
return (
<li className={cx('grid grid-cols-[34px_1fr_auto] items-center gap-2.5 border-b-[1.5px] border-(--line) px-1 py-3 last:border-b-0', mine && 'rounded-2xl bg-white')}>
<span className="text-center font-bagel text-xl text-(--orange)">{no}</span>
<span className="min-w-0">
<b className="block font-jua text-[17px] font-normal">
{title}
{place ? <MapLink place={place}>{title}</MapLink> : title}
{mine && <small className="ml-1.5 font-sans text-xs font-extrabold text-(--rain)">내 지역</small>}
</b>
<small className="block truncate text-[12.5px] font-semibold text-(--ink2)">{sub || '\u00a0'}</small>
@@ -200,74 +123,57 @@ export function SkyPage() {
const rankLoad = loadOf(ranking)
const plan = sky.data?.plan ?? undefined
const spots = (sky.data?.spots ?? []).slice(0, 3)
const days = sky.data?.days ?? []
const items = (ranking.data?.items ?? []).slice(0, 8)
const target = Math.max(0, days.findIndex((d) => d.day === plan?.day))
const best = days.reduce<number>((b, d, i) => (d.score > days[b].score ? i : b), target)
// 서버 outlook 과 같은 기준: 10점 넘게 나을 때만 더 나은 날로 표시
const better = days.length > 0 && days[best].score - days[target].score > 10 ? best : -1
const target = sky.data?.days?.find((d) => d.day === plan?.day)
const sunset = plan?.timeline?.find((t) => t.kind === 'sun')?.at
return (
<section aria-label="노을" aria-busy={load === 'loading'} className={cx('transition-opacity', sky.isPlaceholderData && 'opacity-60')}>
{/* 히어로 상자는 불러오는 중·실패·빈 값 모두 같은 크기 */}
<div className={HERO}>
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:16%]" aria-hidden="true" />
<p className="relative m-0 text-[13px] font-extrabold">
<div className={cx(HERO, `b-sit-${target?.situation ?? 3}`)}>
<i className="b-sit-sun pointer-events-none absolute bottom-6 left-1/2 -ml-[56px] size-[112px] rounded-full" aria-hidden="true" />
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:22%]" aria-hidden="true" />
{/* 하늘 위 흰 글씨 대비가 모자라 어두운 바탕을 깐다 */}
<p className="relative z-[1] m-0 self-start rounded-full bg-[rgb(30_18_60/0.35)] px-2.5 py-0.5 text-[13px] font-extrabold">
{plan?.when ?? '오늘'} 노을 · {region.name}
</p>
{plan || load === 'loading' ? (
<HeroBody plan={plan} />
<HeroBody plan={plan} sunset={sunset} />
) : (
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroBody />} className="inset-x-0 top-1.5 bottom-0" />
)}
</div>
<Sec title="언제 보면 좋을까" sub={plan ? `${plan.when} 해 지는 시간 기준` : '\u00a0'} />
{(plan || load === 'loading') && <Verdict plan={plan} />}
<Sec title="언제 보면 좋을까" sub="보통 해 진 뒤 10~20분이 가장 붉어요" />
{plan?.timeline?.length || load === 'loading' ? (
<Timeline rows={plan?.timeline} />
) : (
<StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} hold={<Timeline />} className="inset-x-3 top-3 bottom-0" />
)}
<Sec title="내일·모레가 더 나을까" sub={plan?.outlook || '\u00a0'} />
{days.length > 0 ? (
<div className="grid grid-cols-3 gap-2 p-3">
{days.map((d, i) => (
<div key={d.day} className={cx('rounded-[20px] bg-white p-3 text-center shadow-[inset_0_-5px_0_var(--shade)]', i === better && 'ring-2 ring-[#d6457a] ring-inset')}>
<small className="block text-[12.5px] font-extrabold text-(--ink2)">{dayLabel(d.day, i)}</small>
<b className={cx('block font-bagel text-[30px] font-normal', d.score < 60 ? 'text-(--ink2)' : 'text-[#d6457a]')}>{d.score}</b>
<span className="block text-xs font-bold text-(--ink2)">{d.grade_label}</span>
</div>
))}
</div>
) : load === 'loading' ? (
<DaysSkel />
) : (
<StateBox load="ready" empty={load === 'ready' ? '앞으로 3일 노을 정보가 없어요.' : '앞으로 3일 노을을 불러오지 못했어요.'} hold={<DaysSkel />} className="inset-3" />
)}
<Sec title="가까운 노을 명소" sub={sky.data?.sunset_azimuth != null ? `해 지는 ${compass(sky.data.sunset_azimuth)}쪽이 트인 곳, 가까운 순` : '서쪽이 트인 곳, 가까운 순'} />
{/* 더 나은 날이 있을 때만 */}
{plan?.outlook && <p className="mx-3 mt-3 mb-0 rounded-[22px] bg-[#ffe6ec] px-4 py-3 text-[14px] font-bold text-[#7a2a4a]">{plan.outlook}</p>}
<Sec title="가까운 노을 명소" sub="가까운 순 · 방향은 내 동네에서 본 쪽" />
{spots.length ? (
<>
<SpotMap region={region} spots={spots} azimuth={sky.data?.sunset_azimuth} />
<ul className="mx-3 mt-1.5 flex flex-col">
{spots.map((p) => (
<Li key={p.no} no={p.no} title={p.name} sub={p.description} right={`${p.distance_km}km`} />
))}
{/* 3곳이 안 되면 빈 줄로 스켈레톤 높이를 지켜 아래 순위가 밀리지 않게 */}
{THREE.slice(spots.length).map((i) => (
<LiSkel key={`ghost-${i}`} ghost />
))}
</ul>
</>
<ul className="mx-3 mt-1.5 flex flex-col">
{spots.map((p) => (
<Li key={p.no} no={p.no} title={p.name} sub={p.direction ? `${p.direction}쪽` : null} right={`${p.distance_km}km`} place={p.name} />
))}
{/* 3곳이 안 되면 빈 줄로 스켈레톤 높이를 지켜 아래 순위가 밀리지 않게 */}
{THREE.slice(spots.length).map((i) => (
<LiSkel key={`ghost-${i}`} ghost />
))}
</ul>
) : load === 'loading' ? (
<SpotsSkel />
) : (
// 실패 안내·다시 시도는 위 히어로에 한 번만. 여기는 지도·목록 자리만 지킨다
// 실패 안내·다시 시도는 위 히어로에 한 번만. 여기는 목록 자리만 지킨다
<StateBox load="ready" empty={load === 'ready' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} hold={<SpotsSkel />} className="inset-x-3 top-3 bottom-0" />
)}
<Sec title="전국 노을 순위" sub="오늘 기준" />
<Sec title="전국 노을 순위" sub={ranking.data?.summary ?? '오늘 기준'} />
{items.length ? (
<ul className="mx-3 mt-1.5 flex flex-col">
{items.map((r) => (
<Li key={r.region_code} no={r.rank} title={r.name} sub={r.note} right={`${r.score}점`} mine={r.region_code === region.code} />
<Li key={r.region_code} no={r.rank} title={r.name} sub={[r.note, r.situation_label].filter(Boolean).join(' · ')} right={`${r.score}점`} mine={r.region_code === region.code} />
))}
</ul>
) : rankLoad === 'loading' ? (