diff --git a/TODO.md b/TODO.md index 154c301..08106d0 100644 --- a/TODO.md +++ b/TODO.md @@ -22,6 +22,7 @@ | [x] | 행사 독립 카드 최대 3장, 피드 무작위 노출 (하루 같은 자리) | 10/2 회의 | `backend/services/feed_service.py` | | [x] | 계절 소식 제철 7개 추가 (햇밤·햇땅콩·은행·고구마·귤·부사·김장) — 피드백 대기 | 10/2 회의 | `backend/seed/article.json` | | [x] | 새 각 추가 (야구·공부·넷플릭스·군밤) | 10/2 회의 | `backend/seed/index_definition.json` | +| [x] | 각 늘리기 27→34 (골프·집콕·낚시·드라이브·연날리기·물놀이·김장), 집콕각은 미세먼지 탁할수록 좋게 | 사용자 요청 | `backend/seed/index_definition.json`, `backend/services/calc/index_calc.py` | | [x] | 주말 전국 지역 랭킹 — 노을 순위 대표 30곳의 토·일 '나들이 날씨 점수'(낮 10~17시 비 40·기온 35·하늘 15·바람 10, 비 60%↑면 최대 30점) 순위. `GET /v1/week/ranking`, 주말 화면 '이번 주말 전국 날씨 순위'(토/일 탭, 10위까지). 워커가 06:40·18:40에 계산해 Redis에 13시간 저장, 없으면 API가 그 자리에서 계산 | 10/2 회의 최종 그림 | `backend/services/weekend_rank.py`, `backend/services/calc/index_calc.py` (`outing`), `frontend/src/b/WeekPage.tsx` | | [x] | 노을 명소 지역별 목록 연결 — 지금 명소 데이터가 서울 마포구 3곳뿐이고 구 코드로만 찾아서 분당구 등은 하나도 안 나옴 | 10/2 회의 (추후), 사용자 지적 | `backend/seed/sunset_spot.csv`, `backend/services/sky_service.py` | | [ ] | 노을 명소 30km 안에 하나도 없는 구 89/256 — 광주·대전·세종·충북·강원·경북 내륙·전북 내륙 등. TourAPI 키워드로는 안 잡혀 직접 추가하거나 반경을 넓힐지 결정 필요 | 명소 확충 결과 | `backend/seed/sunset_spot.csv`, `backend/services/sky_service.py` | diff --git a/backend/scripts/gen_gak_doc.py b/backend/scripts/gen_gak_doc.py index 4328f7f..63e93e5 100644 --- a/backend/scripts/gen_gak_doc.py +++ b/backend/scripts/gen_gak_doc.py @@ -70,7 +70,13 @@ def zero(z): return s + (f" 최대 {z['cap']}점" if "cap" in z else " 0점") -AX = [("temp", "기온", temp), ("rain", "비", rain), ("wind", "바람", wind), ("humidity", "습도", hum), ("air", "미세먼지", None), +def air(r): + if r["full"] > r["zero"]: + return f"초미세먼지 높을수록 좋음 ({r['zero']}㎍/㎥=0점 → {r['full']}㎍/㎥=100점)" + return "초미세먼지 낮을수록 좋음" + + +AX = [("temp", "기온", temp), ("rain", "비", rain), ("wind", "바람", wind), ("humidity", "습도", hum), ("air", "미세먼지", air), ("uv", "자외선", lambda r: f"자외선 {r['full']} 이하면 만점, {r['zero']} 이상이면 0점 (Open-Meteo)"), ("sun", "햇빛", lambda r: f"해 난 비율 {round(r['full'] * 100)}% 이상이면 만점, {round(r['zero'] * 100)}% 이하면 0점 (Open-Meteo)"), ("view", "가시거리", lambda r: f"{r['full']}km 이상이면 만점, {r['zero']}km 이하면 0점 (Open-Meteo)"), @@ -91,7 +97,7 @@ def main() -> None: P("- 최종 점수 = 비중대로 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 점수 ÷ 100). 비중 0%인 요소는 '가장 낮은 요소'에서 뺍니다. 가장 낮은 요소가 0점이면 25%가 깎입니다.") P("- '0점 조건'에 걸리면 0점, '최대 N점' 조건에 걸리면 N점을 넘지 못합니다.") P("- 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다.") - P("- 미세먼지는 모든 각이 같은 규칙입니다: 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점.") + P("- 미세먼지는 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점입니다. 집콕각처럼 규칙을 따로 적은 각만 거꾸로(탁할수록 좋음) 셉니다.") P("- 바람·미세먼지·노을 정보가 없으면 70점으로 둡니다.\n") P("## 한눈에 보기\n") P("| 순서 | 각 | 코드 | 분류 | 시간대 | 기온 | 비 | 바람 | 습도 | 미세먼지 | 시간 | 재미 각 | 계절 핵심 |") @@ -111,7 +117,7 @@ def main() -> None: w = x.get("weight_" + key, 0) if key in _OPTIONAL and not w: continue - rule = "초미세먼지 낮을수록 좋음" if fn is None else fn(x["factor_rules"][key]) + rule = fn(x["factor_rules"].get(key, {"zero": 75, "full": 15})) P(f" - {label} {w}%: {rule}") zs = [zero(z) for z in x["zero_rules"]] P(f"- 점수 깎이는 조건: {', '.join(zs) if zs else '없음'}") diff --git a/backend/seed/index_definition.json b/backend/seed/index_definition.json index 1eab697..4628862 100644 --- a/backend/seed/index_definition.json +++ b/backend/seed/index_definition.json @@ -1764,5 +1764,515 @@ "80": "영하 가까운 저녁, 군밤 품고 걷는 날 🌰" }, "sort_order": 27 + }, + { + "code": "golf", + "name": "골프각", + "icon": "golf", + "category": 1, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "오전 7시~오후 5시, 필드에서 라운딩하기 좋은 정도", + "windows": [ + { + "from": 7, + "to": 12 + }, + { + "from": 12, + "to": 17 + } + ], + "weight_temp": 30, + "weight_rain": 30, + "weight_wind": 25, + "weight_humidity": 5, + "weight_air": 5, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 0, + "weight_time": 5, + "factor_rules": { + "temp": { + "type": "range", + "lo": 15, + "hi": 24 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 3, + "limit": 9 + }, + "humidity": { + "type": "range", + "lo": 30, + "hi": 60, + "best": 35 + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 70 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 70 + }, + { + "field": "wind_ms", + "op": ">=", + "value": 12 + }, + { + "field": "warning", + "op": "==", + "value": "wind" + } + ], + "limit_description": "골프장 예약, 잔디 상태, 낙뢰는 반영하지 못해요", + "sentences": { + "0": "비 70% 넘거나 바람이 너무 세요. 오늘은 스크린으로!", + "30": "춥거나 덥거나 바람이 공을 흔들어요. 타수는 기대 말기!", + "60": "칠 만해요! 바람 방향만 잘 읽으면 돼요.", + "80": "15~24°에 바람 잔잔, 인생 라운딩 노려볼 날 ⛳" + }, + "sort_order": 28 + }, + { + "code": "jipkok", + "name": "집콕각", + "icon": "jipkok", + "category": 3, + "is_fun": true, + "is_core": false, + "has_detail": true, + "description": "오전 10시~오후 6시, 나가기 싫어 집에 있고 싶은 정도", + "windows": [ + { + "from": 10, + "to": 18 + } + ], + "weight_temp": 30, + "weight_rain": 30, + "weight_wind": 10, + "weight_humidity": 5, + "weight_air": 20, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 0, + "weight_time": 5, + "factor_rules": { + "temp": { + "type": "away", + "lo": 15, + "hi": 24 + }, + "rain": { + "dir": "wet" + }, + "wind": { + "type": "strong" + }, + "humidity": { + "type": "higher" + }, + "air": { + "zero": 15, + "full": 75 + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 60 + } + }, + "zero_rules": [], + "limit_description": "재미로 보는 지수예요", + "sentences": { + "0": "밖이 너무 좋아요. 집에만 있기 아까운 날!", + "30": "나갈까 말까, 소파와 밀당 중이에요.", + "60": "덥거나 춥거나 공기가 탁해요. 집이 최고!", + "80": "비 오고 공기까지 탁해요. 이불 밖은 위험해 🛋️" + }, + "sort_order": 29 + }, + { + "code": "fishing", + "name": "낚시각", + "icon": "fishing", + "category": 1, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "새벽 5~9시·오후 4~7시, 물가에서 낚시하기 좋은 정도", + "windows": [ + { + "from": 5, + "to": 9 + }, + { + "from": 16, + "to": 19 + } + ], + "weight_temp": 25, + "weight_rain": 25, + "weight_wind": 35, + "weight_humidity": 0, + "weight_air": 5, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 0, + "weight_time": 10, + "factor_rules": { + "temp": { + "type": "range", + "lo": 12, + "hi": 24 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 4, + "limit": 10 + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 60 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 70 + }, + { + "field": "wind_ms", + "op": ">=", + "value": 10 + }, + { + "field": "warning", + "op": "==", + "value": "wind" + } + ], + "limit_description": "물때·수온·파도 높이는 반영하지 못해요", + "sentences": { + "0": "비 70% 넘거나 바람이 거세요. 물가는 위험, 오늘은 쉬어요!", + "30": "바람에 찌가 흔들리거나 손이 시려요. 짧게 손맛만!", + "60": "물가 나가볼 만해요! 새벽엔 쌀쌀하니 겉옷 챙기기.", + "80": "12~24°에 물결 잔잔, 입질 기다리기 딱 좋은 날 🎣" + }, + "sort_order": 30 + }, + { + "code": "drive", + "name": "드라이브각", + "icon": "drive", + "category": 1, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "오전 10시~오후 5시, 창문 열고 드라이브하기 좋은 정도", + "windows": [ + { + "from": 10, + "to": 17 + } + ], + "weight_temp": 20, + "weight_rain": 30, + "weight_wind": 5, + "weight_humidity": 5, + "weight_air": 15, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 15, + "weight_time": 10, + "factor_rules": { + "temp": { + "type": "range", + "lo": 15, + "hi": 25 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 6, + "limit": 15 + }, + "humidity": { + "type": "range", + "lo": 30, + "hi": 60, + "best": 35 + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 60 + }, + "view": { + "zero": 5, + "full": 20 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 70, + "cap": 20 + } + ], + "limit_description": "길 막힘과 도로 공사는 반영하지 못해요", + "sentences": { + "0": "비가 쏟아져요. 와이퍼만 바쁜 날, 드라이브는 다음에!", + "30": "하늘이 뿌옇거나 비 기운이 있어요. 가까운 곳만 슬쩍!", + "60": "달릴 만해요! 창문 반쯤 열고 음악 크게.", + "80": "공기 맑고 멀리까지 보여요. 해안도로 달리고 싶은 날 🚗" + }, + "sort_order": 31 + }, + { + "code": "kite", + "name": "연날리기각", + "icon": "kite", + "category": 1, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "오전 11시~오후 4시, 연 날리기 좋은 정도", + "windows": [ + { + "from": 11, + "to": 16 + } + ], + "weight_temp": 20, + "weight_rain": 25, + "weight_wind": 45, + "weight_humidity": 0, + "weight_air": 5, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 0, + "weight_time": 5, + "factor_rules": { + "temp": { + "type": "range", + "lo": 8, + "hi": 22 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "moderate" + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 70 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 70 + }, + { + "field": "gust_ms", + "op": ">=", + "value": 13 + }, + { + "field": "wind_ms", + "op": "<", + "value": 1, + "cap": 30 + } + ], + "limit_description": "전깃줄·나무 없는 넓은 곳인지는 반영하지 못해요", + "sentences": { + "0": "비가 오거나 돌풍이 불어요. 연이 날아가 버려요!", + "30": "바람이 너무 약하거나 너무 세요. 뛰어다녀야 겨우 떠요.", + "60": "연 띄울 만해요! 실은 넉넉하게 감아 가요.", + "80": "초속 2~5m 딱 좋은 바람, 연이 하늘 높이 쭉쭉 🪁" + }, + "sort_order": 32 + }, + { + "code": "waterplay", + "name": "물놀이각", + "icon": "waterplay", + "category": 1, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "오전 11시~오후 5시, 바다·계곡에서 물놀이하기 좋은 정도", + "windows": [ + { + "from": 11, + "to": 17 + } + ], + "weight_temp": 40, + "weight_rain": 25, + "weight_wind": 10, + "weight_humidity": 0, + "weight_air": 0, + "weight_uv": 0, + "weight_sun": 20, + "weight_view": 0, + "weight_time": 5, + "factor_rules": { + "temp": { + "type": "range", + "lo": 27, + "hi": 34, + "best": 30 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 4, + "limit": 12 + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 60 + }, + "sun": { + "zero": 0.2, + "full": 0.8 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 60 + }, + { + "field": "feels_c", + "op": "<", + "value": 20 + } + ], + "limit_description": "수온, 파도 높이, 계곡 물살은 반영하지 못해요", + "sentences": { + "0": "체감 20° 아래거나 비 소식이 있어요. 물놀이는 여름에!", + "30": "물에 들어가면 으슬으슬해요. 발만 담그기!", + "60": "물놀이 괜찮아요! 그늘막이랑 선크림 챙기기.", + "80": "30° 안팎에 쨍쨍, 튜브 들고 풍덩 🏖️" + }, + "sort_order": 33 + }, + { + "code": "kimjang", + "name": "김장각", + "icon": "kimchi", + "category": 3, + "is_fun": false, + "is_core": false, + "has_detail": true, + "description": "오전 9시~오후 4시, 김장하기 좋은 정도", + "windows": [ + { + "from": 9, + "to": 16 + } + ], + "weight_temp": 50, + "weight_rain": 25, + "weight_wind": 10, + "weight_humidity": 0, + "weight_air": 5, + "weight_uv": 0, + "weight_sun": 0, + "weight_view": 0, + "weight_time": 10, + "factor_rules": { + "temp": { + "type": "range", + "lo": 0, + "hi": 10, + "best": 5 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 4, + "limit": 10 + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "weekday", + "sat": 100, + "sun": 100, + "holiday": 100, + "default": 50 + } + }, + "zero_rules": [ + { + "field": "feels_c", + "op": ">=", + "value": 18 + } + ], + "limit_description": "배추 작황과 값, 집집마다 김장 날짜는 반영하지 못해요", + "sentences": { + "0": "아직 18° 넘어요. 지금 담그면 김치가 금방 쉬어요!", + "30": "조금 이르거나 손이 꽁꽁 얼어요. 날을 다시 골라 봐요.", + "60": "김장할 만해요! 고무장갑 안에 면장갑 하나 더.", + "80": "0~10°에 비 없고 바람 잔잔, 김장 날 잡는 날 🥬" + }, + "sort_order": 34 } ] \ No newline at end of file diff --git a/backend/services/calc/index_calc.py b/backend/services/calc/index_calc.py index f64710c..1b2e8ef 100644 --- a/backend/services/calc/index_calc.py +++ b/backend/services/calc/index_calc.py @@ -154,10 +154,15 @@ def humidity_score(rule: dict, humidity: float) -> tuple[int, str]: return 50, f"{note}, 이 각엔 상관없어 50점으로 둬요" -def air_score(pm25: Optional[int], label: Optional[str]) -> tuple[int, str]: +_AIR_RULE = {"zero": 75, "full": 15} + + +def air_score(pm25: Optional[int], label: Optional[str], rule: Optional[dict] = None) -> tuple[int, str]: + """rule 이 없으면 맑을수록 좋음. 집콕각처럼 탁할수록 좋은 각은 {"zero": 15, "full": 75} 로 뒤집는다.""" if pm25 is None: return _UNKNOWN, f"미세먼지 정보가 없어 {_UNKNOWN}점으로 둬요" - return _linear(pm25, 75, 15), f"초미세먼지 {pm25}㎍/㎥{', ' + label if label else ''}" + rule = rule or _AIR_RULE + return _linear(pm25, rule["zero"], rule["full"]), f"초미세먼지 {pm25}㎍/㎥{', ' + label if label else ''}" def uv_score(rule: dict, uv: Optional[float]) -> tuple[int, str]: @@ -208,7 +213,8 @@ def axis_label(axis: str, rules: dict) -> str: if axis == "rain": return "비 옴" if rules["rain"]["dir"] == "wet" else "비 안 옴" if axis == "air": - return "공기 맑음" + rule = rules.get("air", _AIR_RULE) + return "공기 탁함" if rule["full"] > rule["zero"] else "공기 맑음" table = {"temp": _TEMP_LABEL, "wind": _WIND_LABEL, "humidity": _HUMIDITY_LABEL, "time": _TIME_LABEL}[axis] return table[rules[axis]["type"]] @@ -304,7 +310,7 @@ def evaluate(definition, windows: list[list[Hour]], ctx: Context) -> Optional[Re "rain": rain_score(rules["rain"], max_prob, raining, until if max_prob > own_prob else ""), "wind": wind_score(rules["wind"], max(winds) if winds else None), "humidity": humidity_score(rules["humidity"], mean(h.humidity for h in hours)), - "air": air_score(ctx.pm25, ctx.air_label), + "air": air_score(ctx.pm25, ctx.air_label, rules.get("air")), "uv": uv_score(rules["uv"], max(uvs, default=None)) if weights["uv"] else (0, ""), "sun": sun_score(rules["sun"], mean(suns) if suns else None) if weights["sun"] else (0, ""), "view": view_score(rules["view"], min(views, default=None)) if weights["view"] else (0, ""), diff --git a/backend/tests/test_feed.py b/backend/tests/test_feed.py index ff47a6f..6135b56 100644 --- a/backend/tests/test_feed.py +++ b/backend/tests/test_feed.py @@ -58,7 +58,7 @@ async def test_feed_assembles_hero_stories_posts_and_bands(offline): body = (await client.get("/v1/feed", params={"region": REGION})).json() assert body["result"]["success"] is True assert body["hero"]["temp_c"] == 20 and body["hero"]["top1"]["rank"] == 1 and "top3" not in body["hero"] - assert len(body["stories"]) == 27 + assert len(body["stories"]) == 34 weather = next(p for p in body["posts"] if p["post_type"] == PostType.WEATHER.value) assert [s["kind"] for s in weather["slides"]] == ["hours", "hours"] assert len(weather["slides"][0]["hours"]) == 8 diff --git a/backend/tests/test_index_api.py b/backend/tests/test_index_api.py index 0853b83..87667e6 100644 --- a/backend/tests/test_index_api.py +++ b/backend/tests/test_index_api.py @@ -51,11 +51,11 @@ def fakes(monkeypatch): @pytest.mark.anyio -async def test_index_list_ranks_all_27_with_today_tomorrow_weekend_trend(fakes): +async def test_index_list_ranks_all_34_with_today_tomorrow_weekend_trend(fakes): async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: body = (await client.get("/v1/index/list", params={"region": REGION})).json() assert body["result"]["success"] is True - assert len(body["items"]) == 27 and len(body["top3"]) == 3 + assert len(body["items"]) == 34 and len(body["top3"]) == 3 scores = [i["score"] for i in body["items"]] assert scores == sorted(scores, reverse=True) today = now_kst().date() diff --git a/backend/tests/test_index_calc.py b/backend/tests/test_index_calc.py index ae67e4c..8c144a6 100644 --- a/backend/tests/test_index_calc.py +++ b/backend/tests/test_index_calc.py @@ -1,10 +1,14 @@ +import json from dataclasses import replace from datetime import date, datetime, timezone +from pathlib import Path from types import SimpleNamespace +import pytest + from common.enums import RainType, Sky from services.calc.index_calc import ( - OUTING_HOURS, Context, DayForecast, Hour, axis_label, estimate, evaluate, hour_temp, outing, outing_estimate, rain_score, sun_score, temp_score, + OUTING_HOURS, Context, DayForecast, Hour, air_score, axis_label, estimate, evaluate, hour_temp, outing, outing_estimate, rain_score, sun_score, temp_score, uv_score, view_score, zero_rules_text, ) from services.calc.moon import illumination @@ -222,3 +226,40 @@ def test_outing_estimate_from_mid_forecast(): assert r.reason.startswith("비 20% · 낮 ") assert outing_estimate(_fc(pm=60)).score <= 30 assert outing_estimate(_fc(lo=None, hi=None)) is None + + +def test_air_rule_can_reverse_so_dusty_air_scores_high(): + rule = {"zero": 15, "full": 75} + assert air_score(80, None, rule)[0] == 100 and air_score(10, None, rule)[0] == 0 + assert air_score(10, None)[0] == 100 + assert axis_label("air", {"air": rule}) == "공기 탁함" and axis_label("air", {}) == "공기 맑음" + + +_SEED = {x["code"]: SimpleNamespace(**x) for x in json.loads((Path(__file__).parents[1] / "seed" / "index_definition.json").read_text(encoding="utf-8"))} +_SAT, _WED = date(2026, 10, 10), date(2026, 10, 7) + + +def _seed_score(code, day=_SAT, pm25=10, **hour): + d = _SEED[code] + windows = [[_h(h, **hour) for h in range(w["from"], w["to"])] for w in d.windows] + return evaluate(d, windows, replace(CTX, day=day, pm25=pm25)).score + + +@pytest.mark.parametrize("code, good, bad", [ + ("golf", dict(feels=19.0, wind=2.0, hum=45), dict(feels=18.0, prob=80, rain=RainType.RAIN)), + ("jipkok", dict(feels=4.0, prob=90, rain=RainType.RAIN, wind=7.0, hum=85), dict(feels=20.0, wind=1.0, hum=40)), + ("fishing", dict(feels=22.0, wind=3.0), dict(feels=17.0, wind=11.0)), + ("drive", dict(feels=23.0, wind=4.0, hum=45, visibility_km=18.0), dict(feels=18.0, prob=80, rain=RainType.RAIN, visibility_km=5.0)), + ("kite", dict(feels=19.0, wind=6.0), dict(feels=14.0, wind=0.5)), + ("waterplay", dict(feels=28.0, wind=3.0, sunshine_ratio=0.7), dict(feels=18.0, wind=2.0, sunshine_ratio=0.3)), + ("kimjang", dict(feels=9.0, wind=3.0), dict(feels=20.0, wind=2.0)), +]) +def test_new_gak_good_day_high_bad_day_low(code, good, bad): + assert 80 <= _seed_score(code, pm25=60 if code == "jipkok" else 10, **good) < 100 + assert _seed_score(code, **bad) <= 30 + + +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 diff --git a/docs/각_계산기준.md b/docs/각_계산기준.md index 6263703..c3b6d49 100644 --- a/docs/각_계산기준.md +++ b/docs/각_계산기준.md @@ -8,7 +8,7 @@ - 최종 점수 = 비중대로 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 점수 ÷ 100). 비중 0%인 요소는 '가장 낮은 요소'에서 뺍니다. 가장 낮은 요소가 0점이면 25%가 깎입니다. - '0점 조건'에 걸리면 0점, '최대 N점' 조건에 걸리면 N점을 넘지 못합니다. - 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다. -- 미세먼지는 모든 각이 같은 규칙입니다: 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점. +- 미세먼지는 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점입니다. 집콕각처럼 규칙을 따로 적은 각만 거꾸로(탁할수록 좋음) 셉니다. - 바람·미세먼지·노을 정보가 없으면 70점으로 둡니다. ## 한눈에 보기 @@ -42,6 +42,13 @@ | 25 | 공부각 | `study` | 집안일 | 13~18시 | 35% | 35% | 10% | 5% | 5% | 10% | ○ | | | 26 | 넷플릭스각 | `netflix` | 집안일 | 20~24시 | 30% | 35% | 15% | 5% | 0% | 15% | ○ | | | 27 | 군밤각 | `chestnut` | 먹고 마시기 | 17~21시 | 55% | 25% | 10% | 0% | 5% | 5% | ○ | | +| 28 | 골프각 | `golf` | 밖에서 놀기 | 7~12시 / 12~17시 | 30% | 30% | 25% | 5% | 5% | 5% | | | +| 29 | 집콕각 | `jipkok` | 집안일 | 10~18시 | 30% | 30% | 10% | 5% | 20% | 5% | ○ | | +| 30 | 낚시각 | `fishing` | 밖에서 놀기 | 5~9시 / 16~19시 | 25% | 25% | 35% | 0% | 5% | 10% | | | +| 31 | 드라이브각 | `drive` | 밖에서 놀기 | 10~17시 | 20% | 30% | 5% | 5% | 15% | 10% | | | +| 32 | 연날리기각 | `kite` | 밖에서 놀기 | 11~16시 | 20% | 25% | 45% | 0% | 5% | 5% | | | +| 33 | 물놀이각 | `waterplay` | 밖에서 놀기 | 11~17시 | 40% | 25% | 10% | 0% | 0% | 5% | | | +| 34 | 김장각 | `kimjang` | 집안일 | 9~16시 | 50% | 25% | 10% | 0% | 5% | 10% | | | ## 각별 자세히 @@ -595,3 +602,145 @@ - 60~79점: 손이 시려요. 따끈한 군밤 한 봉지! - 80~100점: 영하 가까운 저녁, 군밤 품고 걷는 날 🌰 +### 골프각 (`golf`) + +- 설명: 오전 7시~오후 5시, 필드에서 라운딩하기 좋은 정도 +- 분류: 밖에서 놀기 · 아이콘 `golf` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 7~12시 / 12~17시 +- 요소별 규칙 (비중): + - 기온 30%: 체감 15~24°가 좋음 + - 비 30%: 비 안 올수록 좋음 + - 바람 25%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 9m면 0점) + - 습도 5%: 30~60%가 좋음 (최적 35%) + - 미세먼지 5%: 초미세먼지 낮을수록 좋음 + - 시간·요일 5%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 70 +- 점수 깎이는 조건: 비 확률 70% 이상이면 0점, 바람 12m/s 이상이면 0점, wind 특보가 있으면 +- 반영 못 하는 것: 골프장 예약, 잔디 상태, 낙뢰는 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 비 70% 넘거나 바람이 너무 세요. 오늘은 스크린으로! + - 30~59점: 춥거나 덥거나 바람이 공을 흔들어요. 타수는 기대 말기! + - 60~79점: 칠 만해요! 바람 방향만 잘 읽으면 돼요. + - 80~100점: 15~24°에 바람 잔잔, 인생 라운딩 노려볼 날 ⛳ + +### 집콕각 (`jipkok`) + +- 설명: 오전 10시~오후 6시, 나가기 싫어 집에 있고 싶은 정도 +- 분류: 집안일 · 아이콘 `jipkok` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 10~18시 +- 요소별 규칙 (비중): + - 기온 30%: 체감이 15~24°에서 멀수록(덥거나 추울수록) 좋음 + - 비 30%: 비 올수록 좋음 + - 바람 10%: 셀수록 좋음 (초속 8m=100점) + - 습도 5%: 높을수록 좋음 (40%=0점 → 90%=100점) + - 미세먼지 20%: 초미세먼지 높을수록 좋음 (15㎍/㎥=0점 → 75㎍/㎥=100점) + - 시간·요일 5%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 60 +- 점수 깎이는 조건: 없음 +- 반영 못 하는 것: 재미로 보는 지수예요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 밖이 너무 좋아요. 집에만 있기 아까운 날! + - 30~59점: 나갈까 말까, 소파와 밀당 중이에요. + - 60~79점: 덥거나 춥거나 공기가 탁해요. 집이 최고! + - 80~100점: 비 오고 공기까지 탁해요. 이불 밖은 위험해 🛋️ + +### 낚시각 (`fishing`) + +- 설명: 새벽 5~9시·오후 4~7시, 물가에서 낚시하기 좋은 정도 +- 분류: 밖에서 놀기 · 아이콘 `fishing` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 5~9시 / 16~19시 +- 요소별 규칙 (비중): + - 기온 25%: 체감 12~24°가 좋음 + - 비 25%: 비 안 올수록 좋음 + - 바람 35%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 10m면 0점) + - 습도 0%: 상관없음 (50점 고정) + - 미세먼지 5%: 초미세먼지 낮을수록 좋음 + - 시간·요일 10%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 60 +- 점수 깎이는 조건: 비 확률 70% 이상이면 0점, 바람 10m/s 이상이면 0점, wind 특보가 있으면 +- 반영 못 하는 것: 물때·수온·파도 높이는 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 비 70% 넘거나 바람이 거세요. 물가는 위험, 오늘은 쉬어요! + - 30~59점: 바람에 찌가 흔들리거나 손이 시려요. 짧게 손맛만! + - 60~79점: 물가 나가볼 만해요! 새벽엔 쌀쌀하니 겉옷 챙기기. + - 80~100점: 12~24°에 물결 잔잔, 입질 기다리기 딱 좋은 날 🎣 + +### 드라이브각 (`drive`) + +- 설명: 오전 10시~오후 5시, 창문 열고 드라이브하기 좋은 정도 +- 분류: 밖에서 놀기 · 아이콘 `drive` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 10~17시 +- 요소별 규칙 (비중): + - 기온 20%: 체감 15~25°가 좋음 + - 비 30%: 비 안 올수록 좋음 + - 바람 5%: 잔잔할수록 좋음 (초속 6m까지 괜찮음, 15m면 0점) + - 습도 5%: 30~60%가 좋음 (최적 35%) + - 미세먼지 15%: 초미세먼지 낮을수록 좋음 + - 가시거리 15%: 20km 이상이면 만점, 5km 이하면 0점 (Open-Meteo) + - 시간·요일 10%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 60 +- 점수 깎이는 조건: 비 확률 70% 이상이면 최대 20점 +- 반영 못 하는 것: 길 막힘과 도로 공사는 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 비가 쏟아져요. 와이퍼만 바쁜 날, 드라이브는 다음에! + - 30~59점: 하늘이 뿌옇거나 비 기운이 있어요. 가까운 곳만 슬쩍! + - 60~79점: 달릴 만해요! 창문 반쯤 열고 음악 크게. + - 80~100점: 공기 맑고 멀리까지 보여요. 해안도로 달리고 싶은 날 🚗 + +### 연날리기각 (`kite`) + +- 설명: 오전 11시~오후 4시, 연 날리기 좋은 정도 +- 분류: 밖에서 놀기 · 아이콘 `kite` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 11~16시 +- 요소별 규칙 (비중): + - 기온 20%: 체감 8~22°가 좋음 + - 비 25%: 비 안 올수록 좋음 + - 바람 45%: 적당한 바람(초속 2~5m)이 좋음 + - 습도 0%: 상관없음 (50점 고정) + - 미세먼지 5%: 초미세먼지 낮을수록 좋음 + - 시간·요일 5%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 70 +- 점수 깎이는 조건: 비 확률 70% 이상이면 0점, 돌풍 13m/s 이상이면 0점, 바람 1m/s 미만이면 최대 30점 +- 반영 못 하는 것: 전깃줄·나무 없는 넓은 곳인지는 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 비가 오거나 돌풍이 불어요. 연이 날아가 버려요! + - 30~59점: 바람이 너무 약하거나 너무 세요. 뛰어다녀야 겨우 떠요. + - 60~79점: 연 띄울 만해요! 실은 넉넉하게 감아 가요. + - 80~100점: 초속 2~5m 딱 좋은 바람, 연이 하늘 높이 쭉쭉 🪁 + +### 물놀이각 (`waterplay`) + +- 설명: 오전 11시~오후 5시, 바다·계곡에서 물놀이하기 좋은 정도 +- 분류: 밖에서 놀기 · 아이콘 `waterplay` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 11~17시 +- 요소별 규칙 (비중): + - 기온 40%: 체감 27~34°가 좋음 + - 비 25%: 비 안 올수록 좋음 + - 바람 10%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 12m면 0점) + - 습도 0%: 상관없음 (50점 고정) + - 미세먼지 0%: 초미세먼지 낮을수록 좋음 + - 햇빛 20%: 해 난 비율 80% 이상이면 만점, 20% 이하면 0점 (Open-Meteo) + - 시간·요일 5%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 60 +- 점수 깎이는 조건: 비 확률 60% 이상이면 0점, 체감 20° 미만이면 0점 +- 반영 못 하는 것: 수온, 파도 높이, 계곡 물살은 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 체감 20° 아래거나 비 소식이 있어요. 물놀이는 여름에! + - 30~59점: 물에 들어가면 으슬으슬해요. 발만 담그기! + - 60~79점: 물놀이 괜찮아요! 그늘막이랑 선크림 챙기기. + - 80~100점: 30° 안팎에 쨍쨍, 튜브 들고 풍덩 🏖️ + +### 김장각 (`kimjang`) + +- 설명: 오전 9시~오후 4시, 김장하기 좋은 정도 +- 분류: 집안일 · 아이콘 `kimchi` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음 +- 시간대: 9~16시 +- 요소별 규칙 (비중): + - 기온 50%: 체감 0~10°가 좋음 + - 비 25%: 비 안 올수록 좋음 + - 바람 10%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 10m면 0점) + - 습도 0%: 상관없음 (50점 고정) + - 미세먼지 5%: 초미세먼지 낮을수록 좋음 + - 시간·요일 10%: 요일별 점수: 토 100, 일 100, 공휴일 100, 그 외 50 +- 점수 깎이는 조건: 체감 18° 이상이면 0점 +- 반영 못 하는 것: 배추 작황과 값, 집집마다 김장 날짜는 반영하지 못해요 +- 점수 구간별 설명 (상세 창에 나옴): + - 0~29점: 아직 18° 넘어요. 지금 담그면 김치가 금방 쉬어요! + - 30~59점: 조금 이르거나 손이 꽁꽁 얼어요. 날을 다시 골라 봐요. + - 60~79점: 김장할 만해요! 고무장갑 안에 면장갑 하나 더. + - 80~100점: 0~10°에 비 없고 바람 잔잔, 김장 날 잡는 날 🥬 + diff --git a/frontend/public/icons/drive.png b/frontend/public/icons/drive.png new file mode 100644 index 0000000..60567c8 Binary files /dev/null and b/frontend/public/icons/drive.png differ diff --git a/frontend/public/icons/fishing.png b/frontend/public/icons/fishing.png new file mode 100644 index 0000000..d09c99e Binary files /dev/null and b/frontend/public/icons/fishing.png differ diff --git a/frontend/public/icons/golf.png b/frontend/public/icons/golf.png new file mode 100644 index 0000000..b1df518 Binary files /dev/null and b/frontend/public/icons/golf.png differ diff --git a/frontend/public/icons/jipkok.png b/frontend/public/icons/jipkok.png new file mode 100644 index 0000000..238830e Binary files /dev/null and b/frontend/public/icons/jipkok.png differ diff --git a/frontend/public/icons/kite.png b/frontend/public/icons/kite.png new file mode 100644 index 0000000..f437a7b Binary files /dev/null and b/frontend/public/icons/kite.png differ diff --git a/frontend/public/icons/waterplay.png b/frontend/public/icons/waterplay.png new file mode 100644 index 0000000..d8f59a7 Binary files /dev/null and b/frontend/public/icons/waterplay.png differ diff --git a/frontend/src/b/lib.ts b/frontend/src/b/lib.ts index 5e6b4da..7f64e84 100644 --- a/frontend/src/b/lib.ts +++ b/frontend/src/b/lib.ts @@ -1,6 +1,6 @@ import type { CSSProperties } from 'react' -const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask']) +const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay']) const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert']) /** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */