feat: 10/6 회의 반영 — 각 점수 하향, 주말 카드 매일·다음 주말, 일반구를 시로 합침
- 각 점수: 편한 범위 안에서도 최적값에서만 100, 가장 나쁜 요인이 전체를 끌어내림 - 피드 노을 시간대 각 정렬 오류 수정 - 주말 카드 매일 노출, 예보가 닿으면 다음 주말 슬라이드 추가, 주말·행사 탭 열흘 - 지역 256→230 (일반구 39개를 시 13개로) - 회의 기록과 TODO.md 추가
This commit is contained in:
1 parent
a9ddbaab3c
commit
14ddebd040
12 files changed
+156
-76
No files matched your search
@@ -10,6 +10,8 @@ AXES = ("temp", "rain", "wind", "humidity", "air", "time")
|
||||
_WEEKDAY = ("mon", "tue", "wed", "thu", "fri", "sat", "sun")
|
||||
_WEEKDAY_KO = ("월", "화", "수", "목", "금", "토", "일")
|
||||
_UNKNOWN = 70
|
||||
_EDGE = 85
|
||||
_WORST_PULL = 0.25
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -53,13 +55,21 @@ def _linear(v: float, zero: float, full: float) -> int:
|
||||
return _clamp((v - zero) / (full - zero) * 100)
|
||||
|
||||
|
||||
def _peak(v: float, lo: float, hi: float, best: Optional[float], per_out: float) -> int:
|
||||
"""최적값에서만 100. 편한 범위 끝은 _EDGE, 범위 밖은 한 단위마다 per_out 씩 깎는다."""
|
||||
best = (lo + hi) / 2 if best is None else best
|
||||
if v < lo or v > hi:
|
||||
return _clamp(_EDGE - per_out * min(abs(v - lo), abs(v - hi)))
|
||||
side = (best - lo) if v < best else (hi - best)
|
||||
return _clamp(100 - (100 - _EDGE) * (abs(v - best) / side if side else 0))
|
||||
|
||||
|
||||
def temp_score(rule: dict, feels: float) -> tuple[int, str]:
|
||||
t = feels + rule.get("offset", 0)
|
||||
shown = f"정상 {round(t)}°" if rule.get("offset") else f"체감 {round(t)}°"
|
||||
if rule["type"] == "range":
|
||||
lo, hi = rule["lo"], rule["hi"]
|
||||
dist = 0 if lo <= t <= hi else min(abs(t - lo), abs(t - hi))
|
||||
return _clamp(100 - 8 * dist), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if dist == 0 else '밖'}"
|
||||
return _peak(t, lo, hi, rule.get("best"), 8), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if lo <= t <= hi else '밖'}"
|
||||
return _linear(t, rule["zero"], rule["full"]), shown
|
||||
|
||||
|
||||
@@ -74,7 +84,12 @@ def wind_score(rule: dict, wind: Optional[float]) -> tuple[int, str]:
|
||||
return (_UNKNOWN if wind is None else 50), ("바람 정보 없음" if wind is None else f"바람 초속 {wind:g}m")
|
||||
note = f"바람 초속 {wind:g}m"
|
||||
if rule["type"] == "calm":
|
||||
return (100 if wind <= rule["ok"] else _linear(wind, rule["limit"], rule["ok"])), note
|
||||
ok = rule["ok"]
|
||||
if wind <= ok / 2:
|
||||
return 100, note
|
||||
if wind <= ok:
|
||||
return _clamp(100 - (100 - _EDGE) * (wind - ok / 2) / (ok / 2)), note
|
||||
return _clamp(_EDGE * (rule["limit"] - wind) / (rule["limit"] - ok)), note
|
||||
if rule["type"] == "moderate":
|
||||
if 2 <= wind <= 5:
|
||||
return 100, note
|
||||
@@ -85,8 +100,7 @@ def wind_score(rule: dict, wind: Optional[float]) -> tuple[int, str]:
|
||||
def humidity_score(rule: dict, humidity: float) -> tuple[int, str]:
|
||||
note = f"습도 {round(humidity)}%"
|
||||
if rule["type"] == "range":
|
||||
dist = 0 if rule["lo"] <= humidity <= rule["hi"] else min(abs(humidity - rule["lo"]), abs(humidity - rule["hi"]))
|
||||
return _clamp(100 - 2 * dist), note
|
||||
return _peak(humidity, rule["lo"], rule["hi"], rule.get("best"), 2), note
|
||||
if rule["type"] == "higher":
|
||||
return _linear(humidity, 40, 90), note
|
||||
if rule["type"] == "lower":
|
||||
@@ -180,7 +194,8 @@ def evaluate(definition, windows: list[list[Hour]], ctx: Context) -> Optional[Re
|
||||
}
|
||||
factors = {a: v for a, (v, _) in scored.items()}
|
||||
notes = {a: n for a, (_, n) in scored.items()}
|
||||
score = round(sum(factors[a] * weights[a] for a in AXES) / 100)
|
||||
worst = min((factors[a] for a in AXES if weights[a]), default=100)
|
||||
score = round(sum(factors[a] * weights[a] for a in AXES) / 100 * (1 - _WORST_PULL + _WORST_PULL * worst / 100))
|
||||
agg = {
|
||||
"rain_prob": max_prob, "wind_ms": max(winds) if winds else None, "pm25": ctx.pm25,
|
||||
"feels_c": (min(h.feels_c for h in hours), max(h.feels_c for h in hours)),
|
||||
|
||||
Reference in new issue
Block a user