Merge branch 'fix/now-slot-summary-hour' — 지금 구간 날씨 줄을 지금 시각으로, 단풍 지도 좋아요·댓글 복구
This commit is contained in:
commit
48299e3ac5
5 files changed
+24
-7
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -639,7 +639,7 @@ export function TodayPage() {
|
||||
<StateBox load="ready" empty={load === 'ready' ? '오늘 올라온 글이 아직 없어요.' : '글을 불러오지 못했어요.'} hold={<PostsSkel />} className="inset-x-3 top-3.5 bottom-auto" />
|
||||
)}
|
||||
{/* 단풍철엔 단풍 지도를 포스트 맨 앞에 */}
|
||||
{load !== 'loading' && posts.length > 0 && <FoliageCard />}
|
||||
{load !== 'loading' && posts.length > 0 && <FoliageCard post={f?.foliage_post} />}
|
||||
{posts.map((p, i) => {
|
||||
const t = talkAt(i)
|
||||
const ev = eventNo.get(p.post_id)
|
||||
|
||||
@@ -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 (
|
||||
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" caption={peak.length ? `지금 절정 ${peak.length}곳: ${peak.slice(0, 5).map((m) => m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}>
|
||||
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" pinned={{ key: 'foliage_post', post }} caption={peak.length ? `지금 절정 ${peak.length}곳: ${peak.slice(0, 5).map((m) => m.name).join(' · ')}${peak.length > 5 ? ' 외' : ''}` : undefined}>
|
||||
<div className="b-keep-bg relative bg-[#fff6ea] px-4 pt-4 pb-3 text-[#28304a]">
|
||||
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
|
||||
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">{headline(spots)}</p>
|
||||
|
||||
Reference in new issue
Block a user