From 751beb6e3307d402738eb35be820282cea9b280f Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 29 Oct 2026 16:12:40 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=98=A4=EB=8A=98=EC=9D=98=20?= =?UTF-8?q?=EA=B0=81=20=EC=A4=84=20=EB=82=A0=EC=94=A8=EA=B0=80=20=EC=A7=80?= =?UTF-8?q?=EA=B8=88=20=EC=8B=9C=EA=B0=81=EC=9D=B4=20=EC=95=84=EB=8B=88?= =?UTF-8?q?=EB=9D=BC=20=EB=82=A8=EC=9D=80=20=EA=B5=AC=EA=B0=84=20=EA=B0=80?= =?UTF-8?q?=EC=9A=B4=EB=8D=B0=20=EC=8B=9C=EA=B0=81(4=EC=8B=9C=2010?= =?UTF-8?q?=EB=B6=84=EC=9D=B8=EB=8D=B0=20'=EC=98=A4=ED=9B=84=205=EC=8B=9C'?= =?UTF-8?q?)=EC=9C=BC=EB=A1=9C=20=EB=B3=B4=EC=9D=B4=EB=8D=98=20=EA=B2=83?= =?UTF-8?q?=20=E2=80=94=20=EC=A7=80=EA=B8=88=20=EA=B5=AC=EA=B0=84=EC=9D=80?= =?UTF-8?q?=20=EC=A7=80=EA=B8=88=20=EC=8B=9C=EA=B0=81=20=EB=82=A0=EC=94=A8?= =?UTF-8?q?=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/calc/index_calc.py | 6 +++++- backend/services/index_service.py | 8 +++++--- backend/tests/test_index_slots.py | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/backend/services/calc/index_calc.py b/backend/services/calc/index_calc.py index 7dc9fdb..9e3a636 100644 --- a/backend/services/calc/index_calc.py +++ b/backend/services/calc/index_calc.py @@ -295,7 +295,11 @@ _SKY_WORD = {Sky.CLEAR: "맑음", Sky.PARTLY: "구름 많음", Sky.CLOUDY: "흐 def _summary(hours: list[Hour]) -> str: - mid = hours[len(hours) // 2] + return summary_line(hours[len(hours) // 2]) + + +def summary_line(mid: Hour) -> str: + """그 시각 날씨 한 줄 (오후 5시 13°, 비 60%).""" wind = mid.wind_ms tag = f"비 {mid.rain_prob}%" if mid.rain_prob >= 50 else ( "바람 살랑" if wind is not None and wind <= 2 else "바람 조금" if wind is not None and wind <= 5 else "바람 강함" if wind is not None else _SKY_WORD[mid.sky] diff --git a/backend/services/index_service.py b/backend/services/index_service.py index 6294c0b..0e26f0c 100644 --- a/backend/services/index_service.py +++ b/backend/services/index_service.py @@ -19,7 +19,7 @@ from crud.weather_crud import WeatherCRUD from crud.week_crud import WeekCRUD from services.air_service import GRADE_LABEL, AirService from services.calc.day_slot import NIGHT_END_HOUR, SLOTS, slot_hours, slot_of -from services.calc.index_calc import AXES, Context, DayForecast, Hour, Result, estimate, evaluate, priority_score, rank_score +from services.calc.index_calc import AXES, Context, DayForecast, Hour, Result, estimate, evaluate, priority_score, rank_score, summary_line from services.calc.moon import night, up_ratio, view_line from services.calc.sun import sun_times from services.external.open_meteo import is_dark_slot @@ -240,8 +240,7 @@ def slot_results( """각 구간의 날씨로 평가한다. 활동 시간대와 안 겹쳐도 계산하되 시간 요소는 0점. now 가 있으면 현재 구간은 남은 시각만 본다.""" hours_by_slot = slot_hours(day, sunset_at) hours_by_slot[EARLY] = set(range(NIGHT_END_HOUR)) - if now: - _trim_passed(hours_by_slot, day, sunset_at, now) + cur = _trim_passed(hours_by_slot, day, sunset_at, now) if now else None activity = [{h % 24 for h in w} for w in window_hours(defn, day, region)] out = {} for key, hours in hours_by_slot.items(): @@ -253,6 +252,9 @@ def slot_results( windows = windows_for(window, day, region, by_at, by_om, only=hours) result = evaluate(defn, windows, replace(ctx, time_matches=matches)) if result is not None: + # 지금 구간 줄은 남은 시간의 가운데가 아니라 지금 시각 날씨로 + if key == cur and windows and windows[0]: + result.summary = summary_line(windows[0][0]) out[key] = result return out diff --git a/backend/tests/test_index_slots.py b/backend/tests/test_index_slots.py index ad14fae..ac8c249 100644 --- a/backend/tests/test_index_slots.py +++ b/backend/tests/test_index_slots.py @@ -110,3 +110,13 @@ def test_running_muggy_morning_does_not_exceed_original_weather_score(): results = slot_results(RUNNING, SAT, REGION, hourly, {}, replace(CTX, pm25=30), start + timedelta(hours=18)) assert results["morning"].factors["time"] == 100 assert results["morning"].score <= 67 + + +def test_now_slot_summary_shows_current_hour_not_middle_of_rest(): + """오후 4시 10분이면 지금 구간 줄은 남은 16~18시의 가운데(5시)가 아니라 지금(4시) 날씨로.""" + start = kst_midnight(SAT) + hourly = _hourly(SAT) | _hourly(SAT + timedelta(days=1)) + sunset = start + timedelta(hours=17, minutes=30) + results = slot_results(RUNNING, SAT, REGION, hourly, {}, CTX, sunset, now=start + timedelta(hours=16, minutes=10)) + assert results["evening"].summary.startswith("오후 4시"), results["evening"].summary + assert results["night"].summary.startswith("오후 4시") is False From 4f36451da0014d9b2c2994ae90ed27dc0730c163 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 29 Oct 2026 16:12:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EB=8B=A8=ED=92=8D=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=20=EC=B9=B4=EB=93=9C=EC=97=90=20=EC=A2=8B=EC=95=84?= =?UTF-8?q?=EC=9A=94=C2=B7=EB=8C=93=EA=B8=80=EC=9D=B4=20=EB=8B=A4=EC=8B=9C?= =?UTF-8?q?=20=EB=B3=B4=EC=9D=B4=EA=B2=8C=20=E2=80=94=2010/27=20=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=EC=9C=84=EC=B9=98=EB=A5=BC=20=EC=98=AE=EA=B8=B0?= =?UTF-8?q?=EB=A9=B0=20=EB=B9=A0=EC=A7=84=20foliage=5Fpost=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/TodayPage.tsx | 2 +- frontend/src/b/foliageMap.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index c3b848d..662bcec 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -639,7 +639,7 @@ export function TodayPage() { } className="inset-x-3 top-3.5 bottom-auto" /> )} {/* 단풍철엔 단풍 지도를 포스트 맨 앞에 */} - {load !== 'loading' && posts.length > 0 && } + {load !== 'loading' && posts.length > 0 && } {posts.map((p, i) => { const t = talkAt(i) const ev = eventNo.get(p.post_id) diff --git a/frontend/src/b/foliageMap.tsx b/frontend/src/b/foliageMap.tsx index 45879d9..f8f4812 100644 --- a/frontend/src/b/foliageMap.tsx +++ b/frontend/src/b/foliageMap.tsx @@ -1,5 +1,6 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react' import { useNavigate } from 'react-router' +import type { PostReaction } from '@nalssigak/shared/api/client/types.gen' import { cx } from '../lib/utils' import { useCarousel } from './carousel' import { headline, ICON_R, LABEL, LABEL_INK, LEAF_SHADOW, MAP_IMG, MAP_SRC, md, placeLabels, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, spread, useFoliage, useLabelSize } from './foliage' @@ -14,7 +15,7 @@ const TAP_R = 24 const RANK_N = 7 /** 피드의 단풍 지도 카드: 1장은 지금 절정인 곳만 잎 아이콘으로(누르면 카드 안에 정보), 2장은 지금 가기 좋은 순위. '지도 크게 보기'로 단풍 지도 페이지 */ -export function FoliageCard() { +export function FoliageCard({ post }: { post?: PostReaction | null }) { const navigate = useNavigate() const { today, spots, inSeason } = useFoliage() const peak = useMemo(() => spots.filter((m) => m.stage === 'peak').sort((a, b) => Number(a.kind === 'ginkgo') - Number(b.kind === 'ginkgo') || a.y - b.y), [spots]) @@ -60,7 +61,7 @@ export function FoliageCard() { // 2번째 장: 지금 절정인 곳을 절정 예상일이 오늘과 가까운 순서로 const ranked = rankNow(spots).slice(0, RANK_N) return ( - m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}> + m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}>

단풍 지도 · {md(today)}

{headline(spots)}