feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선
- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?' - 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준 - 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수 - 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리 - 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정 - 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성 - 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시 - 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집 - 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
1 parent
296a09d6db
commit
ddf05aeb5c
97 files changed
+5475
-720
No files matched your search
@@ -1,8 +1,12 @@
|
||||
from dataclasses import replace
|
||||
from datetime import date, datetime, timezone
|
||||
from types import SimpleNamespace
|
||||
|
||||
from common.enums import RainType, Sky
|
||||
from services.calc.index_calc import Context, Hour, evaluate, rain_score, temp_score, zero_rules_text
|
||||
from services.calc.index_calc import (
|
||||
OUTING_HOURS, Context, DayForecast, Hour, axis_label, estimate, evaluate, hour_temp, outing, outing_estimate, rain_score, temp_score,
|
||||
zero_rules_text,
|
||||
)
|
||||
from services.calc.moon import illumination
|
||||
|
||||
CTX = Context(day=date(2026, 10, 2), is_holiday=False, pm25=10, air_label="좋음", moon=0.5, sunset_score=80, wind_warning=False, lookahead_rain_prob=0)
|
||||
@@ -44,7 +48,7 @@ def test_temp_peaks_at_best_and_loses_8_per_degree_outside():
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24, "best": 22}, 22)[0] == 100
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24}, 15)[0] == 61
|
||||
assert temp_score({"type": "lower", "zero": 25, "full": 5}, 15)[0] == 50
|
||||
assert temp_score({"type": "range", "lo": 10, "hi": 20, "offset": -6}, 21)[1].startswith("정상 15°")
|
||||
assert temp_score({"type": "range", "lo": 10, "hi": 20, "offset": -6}, 21)[1].startswith("산 정상 기준 15°")
|
||||
|
||||
|
||||
def test_temp_away_rises_outside_comfort():
|
||||
@@ -63,7 +67,28 @@ def test_rain_dry_and_wet():
|
||||
def test_zero_rule_forces_zero_and_cap_limits():
|
||||
assert evaluate(_defn(), [[_h(19, prob=80)]], CTX).score == 0
|
||||
capped = _defn(zero_rules=[{"field": "rain_prob", "op": ">=", "value": 70, "cap": 20}])
|
||||
assert evaluate(capped, [[_h(19, prob=70)]], CTX).score <= 20
|
||||
r = evaluate(capped, [[_h(19, prob=70)]], CTX)
|
||||
assert r.score <= 20 and r.zero_reason == "비 확률 70% 이상이라 최대 20점"
|
||||
assert evaluate(_defn(), [[_h(19, prob=80)]], CTX).zero_reason == "비 확률 80% 이상이라 0점"
|
||||
|
||||
|
||||
def test_lookahead_rain_is_named_in_note():
|
||||
defn = _defn(windows=[{"from": 9, "to": 18, "lookahead_days": 2}])
|
||||
r = evaluate(defn, [[_h(10, prob=0)]], replace(CTX, lookahead_rain_prob=60))
|
||||
assert r.notes["rain"] == "모레까지 비 확률 60%"
|
||||
assert evaluate(defn, [[_h(10, prob=0)]], CTX).notes["rain"] == "비 확률 0%"
|
||||
|
||||
|
||||
def test_air_note_has_unit():
|
||||
assert evaluate(_defn(), [[_h(19)]], CTX).notes["air"] == "초미세먼지 10㎍/㎥, 좋음"
|
||||
|
||||
|
||||
def test_axis_label_reads_outward_as_good():
|
||||
rules = _defn().factor_rules
|
||||
assert [axis_label(a, rules) for a in ("temp", "rain", "wind", "humidity", "air", "time")] == \
|
||||
["기온 알맞음", "비 안 옴", "바람 잔잔", "습도 알맞음", "공기 맑음", "요일 알맞음"]
|
||||
wet = {"temp": {"type": "lower"}, "rain": {"dir": "wet"}, "wind": {"type": "strong"}, "humidity": {"type": "higher"}, "time": {"type": "moon"}}
|
||||
assert [axis_label(a, wet) for a in ("temp", "rain", "wind", "humidity", "time")] == ["추움", "비 옴", "바람 셈", "습도 높음", "달 어두움"]
|
||||
|
||||
|
||||
def test_best_window_is_chosen():
|
||||
@@ -73,10 +98,78 @@ def test_best_window_is_chosen():
|
||||
|
||||
def test_zero_rules_text():
|
||||
assert zero_rules_text([{"field": "rain_prob", "op": ">=", "value": 80}, {"field": "wind_ms", "op": ">=", "value": 14}]) == \
|
||||
"비 확률 80% 이상 또는 바람 14m/s 이상이면 바로 0점"
|
||||
"비 확률 80% 이상이거나 바람 14m/s 이상이면 0점"
|
||||
assert zero_rules_text([{"field": "rain_prob", "op": ">=", "value": 70}, {"field": "warning", "op": "==", "value": "wind"}]) == \
|
||||
"비 확률 70% 이상이거나 강풍 특보가 있으면 0점"
|
||||
assert zero_rules_text([{"field": "rain_prob", "op": ">=", "value": 70, "cap": 20}]) == "비 확률 70% 이상이면 최대 20점"
|
||||
assert zero_rules_text([{"field": "pm25", "op": ">=", "value": 75}]) == "초미세먼지 75㎍/㎥ 이상이면 0점"
|
||||
assert zero_rules_text([]) == "없음 (재미로 보는 지수)"
|
||||
|
||||
|
||||
def test_moon_full_and_new():
|
||||
assert illumination(datetime(2000, 1, 6, 18, 14, tzinfo=timezone.utc)) < 0.01
|
||||
assert illumination(datetime(2000, 1, 21, 12, tzinfo=timezone.utc)) > 0.95
|
||||
|
||||
|
||||
def _fc(lo=15.0, hi=23.0, am=0, pm=0, sky=Sky.CLEAR):
|
||||
return DayForecast(temp_min_c=lo, temp_max_c=hi, rain_prob_am=am, rain_prob_pm=pm, sky=sky)
|
||||
|
||||
|
||||
def test_hour_temp_follows_min_at_dawn_and_max_mid_afternoon():
|
||||
assert hour_temp(10, 20, 6) == 10 and hour_temp(10, 20, 15) == 20
|
||||
assert 10 < hour_temp(10, 20, 21) < 20 and hour_temp(10, 20, 30) == 10
|
||||
|
||||
|
||||
def test_estimate_is_flagged_and_unknown_factors_are_70():
|
||||
r = estimate(_defn(), _fc(), [[19, 20]], CTX)
|
||||
assert r.estimated is True
|
||||
assert r.factors["wind"] == 70 and r.factors["humidity"] == 70 and r.factors["air"] == 70
|
||||
assert "예상" in r.summary
|
||||
|
||||
|
||||
def test_estimate_uses_rain_prob_of_the_window_half_day():
|
||||
morning, evening = estimate(_defn(), _fc(am=60, pm=0), [[9, 10]], CTX), estimate(_defn(), _fc(am=60, pm=0), [[19, 20]], CTX)
|
||||
assert morning.factors["rain"] == 40 and evening.factors["rain"] == 100
|
||||
|
||||
|
||||
def test_estimate_applies_rain_zero_rule_only():
|
||||
r = estimate(_defn(zero_rules=[{"field": "rain_prob", "op": ">=", "value": 80}, {"field": "wind_ms", "op": ">=", "value": 1}]), _fc(pm=80), [[19]], CTX)
|
||||
assert r.score == 0 and r.zero_reason.startswith("비 확률 80% 이상")
|
||||
|
||||
|
||||
def test_estimate_without_temps_gives_none():
|
||||
assert estimate(_defn(), _fc(lo=None, hi=None), [[19]], CTX) is None
|
||||
|
||||
|
||||
def _day(**kw):
|
||||
return [_h(h, **kw) for h in range(*OUTING_HOURS)]
|
||||
|
||||
|
||||
def test_outing_perfect_day_is_100_and_reason_names_rain_temp_sky():
|
||||
r = outing(_day(wind=1.0))
|
||||
assert r.score == 100 and r.estimated is False
|
||||
assert r.reason == "비 0% · 체감 21° · 맑음"
|
||||
|
||||
|
||||
def test_outing_cloudy_and_hot_days_lose_points():
|
||||
clear, cloudy, hot = outing(_day()), outing(_day(sky=Sky.CLOUDY)), outing(_day(feels=30.0))
|
||||
assert cloudy.score < clear.score and hot.score < clear.score
|
||||
assert "흐림" in cloudy.reason
|
||||
|
||||
|
||||
def test_outing_rain_caps_score():
|
||||
r = outing(_day(prob=70))
|
||||
assert r.score <= 30 and r.capped
|
||||
assert outing([_h(10, prob=30, rain=RainType.RAIN)] + _day()[1:]).score <= 30
|
||||
|
||||
|
||||
def test_outing_needs_all_hours():
|
||||
assert outing(_day()[:3]) is None
|
||||
|
||||
|
||||
def test_outing_estimate_from_mid_forecast():
|
||||
r = outing_estimate(_fc(lo=12, hi=22, am=10, pm=20))
|
||||
assert r.estimated is True and r.factors["wind"] == 70
|
||||
assert r.reason.startswith("비 20% · 낮 ")
|
||||
assert outing_estimate(_fc(pm=60)).score <= 30
|
||||
assert outing_estimate(_fc(lo=None, hi=None)) is None
|
||||
Reference in new issue
Block a user