fix: 주말 전국 날씨 순위가 전국 비인 날 전부 47점이던 것 — 나들이 점수의 비 상한(최대 30점)을 없애 비 오는 날도 기온·하늘·바람에 따라 점수가 갈림. 바꾸기 표 다시 생성, 순위 캐시 키 v3 (main 939edee 와 같은 내용)
This commit is contained in:
1 parent
e64b001bf9
commit
c02f91c6d8
7 files changed
+46
-42
No files matched your search
@@ -433,7 +433,6 @@ _OUTING_WEIGHTS = {"temp": 35, "rain": 40, "sky": 15, "wind": 10}
|
||||
# 만점 조건을 엄격하게: 기온은 최적 21° ±0.5°, 바람은 초속 1m 이하(ok/2)여야 100점 — 같은 예보를 받는 여러 지역이 한꺼번에 100점이 되던 것을 줄인다
|
||||
_OUTING_RULES = {"temp": {"type": "range", "lo": 17, "hi": 24, "best": 21, "plateau": 0.5}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 2, "limit": 12}}
|
||||
_OUTING_SKY = {Sky.CLEAR: 100, Sky.PARTLY: 80, Sky.CLOUDY: 50}
|
||||
_OUTING_RAIN_PROB, _OUTING_RAIN_CAP = 60, 30
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -442,7 +441,6 @@ class Outing:
|
||||
factors: dict[str, int]
|
||||
notes: dict[str, str]
|
||||
reason: str # 순위 옆 한 줄 근거 ("비 10% · 체감 21° · 맑음")
|
||||
capped: bool # 비 때문에 최대 30점으로 묶였는지
|
||||
estimated: bool = False
|
||||
|
||||
|
||||
@@ -451,12 +449,8 @@ def _outing(scored: dict[str, tuple[int, str]], prob: int, raining: bool, temp_w
|
||||
notes = {a: n for a, (_, n) in scored.items()}
|
||||
worst = min(factors.values())
|
||||
score = round(sum(factors[a] * w for a, w in _OUTING_WEIGHTS.items()) / 100 * (1 - _WORST_PULL + _WORST_PULL * worst / 100))
|
||||
capped = raining or prob >= _OUTING_RAIN_PROB
|
||||
if capped:
|
||||
score = min(score, _OUTING_RAIN_CAP)
|
||||
notes["rain"] += f", 비 확률 {_OUTING_RAIN_PROB}% 이상이거나 비 소식이면 최대 {_OUTING_RAIN_CAP}점"
|
||||
reason = " · ".join(["비 소식" if raining else f"비 {prob}%", temp_word, _SKY_WORD[sky]])
|
||||
return Outing(score=score, factors=factors, notes=notes, reason=reason, capped=capped, estimated=estimated)
|
||||
return Outing(score=score, factors=factors, notes=notes, reason=reason, estimated=estimated)
|
||||
|
||||
|
||||
def outing(hours: list[Hour]) -> Optional[Outing]:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"about": "나들이 점수 바꾸기 표: 원래 점수 0~100 → 표시 점수. 평균 60·표준편차 15. scripts/gen_outing_score_table.py 가 만든다",
|
||||
"period": [
|
||||
"2025-10-22",
|
||||
"2026-10-21"
|
||||
"2025-11-12",
|
||||
"2026-11-11"
|
||||
],
|
||||
"regions": 32,
|
||||
"samples": 11680,
|
||||
@@ -20,14 +20,13 @@
|
||||
13,
|
||||
17,
|
||||
22,
|
||||
25,
|
||||
28,
|
||||
30,
|
||||
32,
|
||||
34,
|
||||
26,
|
||||
29,
|
||||
31,
|
||||
33,
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
37,
|
||||
38,
|
||||
38,
|
||||
39,
|
||||
@@ -37,23 +36,24 @@
|
||||
41,
|
||||
42,
|
||||
42,
|
||||
43,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
45,
|
||||
46,
|
||||
46,
|
||||
47,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
50,
|
||||
48,
|
||||
48,
|
||||
49,
|
||||
49,
|
||||
49,
|
||||
50,
|
||||
50,
|
||||
51,
|
||||
51,
|
||||
51,
|
||||
51,
|
||||
52,
|
||||
54,
|
||||
53,
|
||||
57,
|
||||
61,
|
||||
62,
|
||||
@@ -69,7 +69,6 @@
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
64,
|
||||
65,
|
||||
65,
|
||||
65,
|
||||
@@ -77,7 +76,6 @@
|
||||
66,
|
||||
66,
|
||||
66,
|
||||
66,
|
||||
67,
|
||||
67,
|
||||
67,
|
||||
@@ -86,16 +84,18 @@
|
||||
68,
|
||||
69,
|
||||
69,
|
||||
69,
|
||||
70,
|
||||
70,
|
||||
71,
|
||||
72,
|
||||
73,
|
||||
74,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
83,
|
||||
85,
|
||||
|
||||
@@ -30,7 +30,7 @@ from services.week_service import _icon
|
||||
# 주말 전국 날씨 순위·당일치기 추천. 대표 지역(노을 순위 30곳)과 당일치기 후보 도시의 토·일 나들이 점수를
|
||||
# 워커가 하루 두 번(06:40·18:40) 미리 계산해 Redis 에 둔다. 없으면 순위 API 가 그 자리에서 계산한다.
|
||||
_SEED = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "seed", "trip_city.csv")
|
||||
_KEY = "weekend_rank:v2:{:%Y%m%d}" # v2: 점수를 바꾸기 표로 보정한 값 (옛 점수 캐시를 쓰지 않게 키를 바꿨다)
|
||||
_KEY = "weekend_rank:v3:{:%Y%m%d}" # v3: 비 상한(최대 30점)을 없앤 점수 (옛 점수 캐시를 쓰지 않게 키를 바꿨다)
|
||||
_TTL = 13 * 3600
|
||||
_PARALLEL = 4 # 기상청 동시 호출 수
|
||||
_WAIT_STEPS, _WAIT_SEC = 60, 0.5
|
||||
|
||||
@@ -252,10 +252,20 @@ def test_outing_cloudy_and_hot_days_lose_points():
|
||||
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_rain_lowers_score_without_a_cap():
|
||||
"""비가 오면 비 점수와 가장 낮은 요소 때문에 점수가 내려가지만, 따로 상한으로 묶지는 않는다."""
|
||||
clear = outing(_day())
|
||||
likely = outing(_day(prob=70))
|
||||
raining = outing([_h(10, prob=30, rain=RainType.RAIN)] + _day()[1:])
|
||||
assert raining.score < likely.score < clear.score
|
||||
assert likely.score > 30 and raining.score > 30
|
||||
|
||||
|
||||
def test_outing_rainy_days_keep_their_differences():
|
||||
"""전국이 비인 날에도 기온·하늘에 따라 점수가 갈린다 (예전엔 모두 상한 30점에 걸려 같은 점수였다)."""
|
||||
mild = outing(_day(feels=16.0, sky=Sky.CLOUDY, rain=RainType.RAIN))
|
||||
chilly = outing(_day(feels=14.0, sky=Sky.CLOUDY, rain=RainType.RAIN))
|
||||
assert chilly.score < mild.score
|
||||
|
||||
|
||||
def test_outing_needs_all_hours():
|
||||
@@ -266,7 +276,7 @@ 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 30 < outing_estimate(_fc(pm=60)).score < outing_estimate(_fc(pm=0)).score
|
||||
assert outing_estimate(_fc(lo=None, hi=None)) is None
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_calibrated_outing_reads_the_table():
|
||||
|
||||
def test_day_score_uses_calibrated_value_for_hourly_and_estimated_results():
|
||||
for estimated in (False, True):
|
||||
r = Outing(score=80, factors={}, notes={}, reason="비 0% · 체감 21° · 맑음", capped=False, estimated=estimated)
|
||||
r = Outing(score=80, factors={}, notes={}, reason="비 0% · 체감 21° · 맑음", estimated=estimated)
|
||||
assert outing_day_score(r) == OUTING_SCORE_TABLE[80]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user