From 76a640feab385e305b469c4a38c5b6ead642ee8c Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 8 Oct 2026 16:52:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=98=A4=EB=8A=98=20=EB=82=A0=EC=94=A8?= =?UTF-8?q?=20=EC=A0=90=EC=88=98=20=EA=B8=B0=EC=A4=80=20=EA=B0=95=ED=99=94?= =?UTF-8?q?=20=E2=80=94=20100=EC=A0=90=EC=9D=80=20=EC=B2=B4=EA=B0=90=2021?= =?UTF-8?q?=C2=B10.5=C2=B0=C2=B7=EC=8A=B5=EB=8F=84=2045~55%=C2=B7=ED=96=87?= =?UTF-8?q?=EB=B9=9B=C2=B7=EB=B0=94=EB=9E=8C=201m/s=C2=B7=EC=B4=88?= =?UTF-8?q?=EB=AF=B8=EC=84=B8=EB=A8=BC=EC=A7=80=2010=20=EC=9D=B4=ED=95=98?= =?UTF-8?q?=EA=B0=80=20=EB=AA=A8=EB=91=90=20=EB=A7=9E=EC=9D=84=20=EB=95=8C?= =?UTF-8?q?=EB=A7=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/calc/index_calc.py | 2 +- backend/services/index_service.py | 7 ++++--- backend/tests/test_index_calc.py | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/services/calc/index_calc.py b/backend/services/calc/index_calc.py index 6a54a30..80e8978 100644 --- a/backend/services/calc/index_calc.py +++ b/backend/services/calc/index_calc.py @@ -115,7 +115,7 @@ def temp_score(rule: dict, feels: float) -> tuple[int, str]: shown = f"산 정상 기준 {round(t)}°" if rule.get("offset") else f"체감 {round(t)}°" if rule["type"] == "range": lo, hi = rule["lo"], rule["hi"] - return _range(t, lo, hi, rule.get("best"), _TEMP_PLATEAU, 8), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if lo <= t <= hi else '밖'}" + return _range(t, lo, hi, rule.get("best"), rule.get("plateau", _TEMP_PLATEAU), 8), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if lo <= t <= hi else '밖'}" if rule["type"] == "away": lo, hi = rule["lo"], rule["hi"] dist = 0 if lo <= t <= hi else min(abs(t - lo), abs(t - hi)) diff --git a/backend/services/index_service.py b/backend/services/index_service.py index 97d3b9a..cddde85 100644 --- a/backend/services/index_service.py +++ b/backend/services/index_service.py @@ -30,10 +30,11 @@ _WEEKDAY_KO = ("월", "화", "수", "목", "금", "토", "일") # 메인 하늘 영역의 '오늘 날씨 점수': 낮 9~21시 밖에 나가기 좋은 정도. WEATHER_SCORE_DEF = SimpleNamespace( - weight_temp=40, weight_rain=30, weight_wind=15, weight_humidity=0, weight_air=15, weight_time=0, + weight_temp=30, weight_rain=25, weight_wind=10, weight_humidity=10, weight_air=10, weight_sun=15, weight_time=0, factor_rules={ - "temp": {"type": "range", "lo": 18, "hi": 24}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 4, "limit": 12}, - "humidity": {"type": "ignore"}, "time": {"type": "fixed", "value": 100}, + "temp": {"type": "range", "lo": 18, "hi": 24, "best": 21, "plateau": 0.5}, "rain": {"dir": "dry"}, + "wind": {"type": "calm", "ok": 2, "limit": 10}, "humidity": {"type": "range", "lo": 40, "hi": 60, "best": 50}, + "air": {"zero": 75, "full": 10}, "sun": {"zero": 0.2, "full": 0.9}, "time": {"type": "fixed", "value": 100}, }, zero_rules=[], windows=[{"from": 9, "to": 21}], ) diff --git a/backend/tests/test_index_calc.py b/backend/tests/test_index_calc.py index 8c144a6..fa0c774 100644 --- a/backend/tests/test_index_calc.py +++ b/backend/tests/test_index_calc.py @@ -263,3 +263,14 @@ def test_new_gak_100_only_when_every_factor_is_perfect(): perfect = dict(feels=19.5, wind=1.0, hum=35) assert _seed_score("golf", **perfect) == 100 assert _seed_score("golf", day=_WED, **perfect) < 100 + + +def test_weather_score_100_only_on_perfect_day(): + from services.index_service import WEATHER_SCORE_DEF + + perfect = Context(day=date(2026, 10, 2), is_holiday=False, pm25=8, air_label="좋음", moon=0, sunset_score=None, wind_warning=False, lookahead_rain_prob=0) + hours = [_h(h, feels=21.0, prob=0, wind=0.8, hum=50, sunshine_ratio=1.0) for h in range(9, 22)] + assert evaluate(WEATHER_SCORE_DEF, [hours], perfect).score == 100 + + good = [_h(h, feels=22.5, prob=10, wind=2.5, hum=62, sunshine_ratio=0.7) for h in range(9, 22)] + assert evaluate(WEATHER_SCORE_DEF, [good], replace(perfect, pm25=15)).score < 95