fix: 주말 전국 날씨 순위가 전국 비인 날 전부 47점이던 것 — 나들이 점수의 비 상한(최대 30점)을 없애 비 오는 날도 기온·하늘·바람에 따라 점수가 갈림. 바꾸기 표 다시 생성, 순위 캐시 키 v3

This commit is contained in:
skkim committed 2026-11-13 13:59:08 +09:00
1 parent a80f039444
commit 939edeedb6
7 files changed
+46 -42

No files matched your search

+1 -7
View File
@@ -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]:
+24 -24
View File
@@ -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,
+1 -1
View File
@@ -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