diff --git a/TODO.md b/TODO.md index 8f0995c..c17e46c 100644 --- a/TODO.md +++ b/TODO.md @@ -5,11 +5,11 @@ | [ ] | 서버 배포 + 공유 링크 | 10/6 회의 핵심 업무 | `compose.yaml` | | [x] | 각 점수 하향, 100점은 완벽 조건만 | 10/6 회의 결정 | `backend/services/calc/index_calc.py`, `backend/seed/index_definition.json` | | [ ] | 가중치 재검토 | 10/6 회의 | `backend/seed/index_definition.json` | -| [ ] | 댓글·좋아요·로그인 테스트 | 시연 때 미검증 | `backend/services/reaction_service.py`, `backend/services/auth_service.py` | +| [x] | 댓글·좋아요·로그인 API 테스트 (화면 확인은 아직) | 시연 때 미검증 | `backend/services/reaction_service.py`, `backend/services/auth_service.py` | | [x] | 주말 날씨 평일 상시 노출 + 다음 주 주말까지 (예보 닿는 +10일부터) | 10/6 회의 | `backend/services/week_service.py` | | [ ] | 행사 독립 카드, 피드 무작위 노출 | 10/6 회의 | `backend/services/feed_service.py` | | [ ] | 계절 소식 제철 정보 확충 | 10/6 회의 | `backend/seed/article.json` | -| [ ] | 새 각 추가 (스포츠·공부·넷플릭스·군밤) | 10/6 회의 | `backend/seed/index_definition.json` | +| [x] | 새 각 추가 (야구·공부·넷플릭스·군밤) | 10/6 회의 | `backend/seed/index_definition.json` | | [x] | 지역 단위 조정 (서울 구, 그 외 시·군, 광역시 자치구 유지) | 10/6 회의 | `backend/seed/region.csv`, `backend/seed/ranking_spot.csv` | | [ ] | 주말 전국 지역 랭킹 | 10/6 회의 최종 그림 | `backend/services/week_service.py` | | [ ] | 노을 명소 지역별 목록 연결 | 10/6 회의 (추후) | `backend/seed/sunset_spot.csv` | diff --git a/backend/seed/index_definition.json b/backend/seed/index_definition.json index d5a4a3f..ffa3a4e 100644 --- a/backend/seed/index_definition.json +++ b/backend/seed/index_definition.json @@ -1282,5 +1282,205 @@ "limit_description": "장소 혼잡도는 반영하지 못해요", "sentences": {}, "sort_order": 23 + }, + { + "code": "baseball", + "name": "야구각", + "icon": "baseball", + "category": 1, + "is_fun": true, + "is_core": false, + "has_detail": true, + "description": "저녁 6~10시, 야구장 직관하기 좋은 정도", + "windows": [ + { + "from": 18, + "to": 22 + } + ], + "weight_temp": 25, + "weight_rain": 40, + "weight_wind": 10, + "weight_humidity": 5, + "weight_air": 10, + "weight_time": 10, + "factor_rules": { + "temp": { + "type": "range", + "lo": 15, + "hi": 25 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "calm", + "ok": 3, + "limit": 10 + }, + "humidity": { + "type": "range", + "lo": 40, + "hi": 60 + }, + "time": { + "type": "weekday", + "mon": 10, + "default": 100 + } + }, + "zero_rules": [ + { + "field": "rain_prob", + "op": ">=", + "value": 70 + } + ], + "limit_description": "경기 일정과 시즌(3~10월)은 반영하지 못해요", + "sentences": {}, + "sort_order": 24 + }, + { + "code": "study", + "name": "공부각", + "icon": "study", + "category": 3, + "is_fun": true, + "is_core": false, + "has_detail": true, + "description": "오후 1~6시, 밖에 나가기 싫어서 공부가 잘되는 정도", + "windows": [ + { + "from": 13, + "to": 18 + } + ], + "weight_temp": 35, + "weight_rain": 35, + "weight_wind": 10, + "weight_humidity": 5, + "weight_air": 5, + "weight_time": 10, + "factor_rules": { + "temp": { + "type": "away", + "lo": 15, + "hi": 24 + }, + "rain": { + "dir": "wet" + }, + "wind": { + "type": "strong" + }, + "humidity": { + "type": "higher" + }, + "time": { + "type": "weekday", + "sat": 50, + "sun": 50, + "holiday": 50, + "default": 100 + } + }, + "zero_rules": [], + "limit_description": "사람마다 달라서 재미로 봐 주세요", + "sentences": {}, + "sort_order": 25 + }, + { + "code": "netflix", + "name": "넷플릭스각", + "icon": "netflix", + "category": 3, + "is_fun": true, + "is_core": false, + "has_detail": true, + "description": "밤 8시~자정, 집에서 영화 보기 좋은 정도", + "windows": [ + { + "from": 20, + "to": 24 + } + ], + "weight_temp": 30, + "weight_rain": 35, + "weight_wind": 15, + "weight_humidity": 5, + "weight_air": 0, + "weight_time": 15, + "factor_rules": { + "temp": { + "type": "lower", + "zero": 22, + "full": 0 + }, + "rain": { + "dir": "wet" + }, + "wind": { + "type": "strong" + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "weekday", + "fri": 100, + "sat": 100, + "default": 60 + } + }, + "zero_rules": [], + "limit_description": "재미로 보는 지수예요", + "sentences": {}, + "sort_order": 26 + }, + { + "code": "chestnut", + "name": "군밤각", + "icon": "chestnut", + "category": 2, + "is_fun": true, + "is_core": false, + "has_detail": true, + "description": "저녁 5~9시, 길거리 군밤이 당기는 정도", + "windows": [ + { + "from": 17, + "to": 21 + } + ], + "weight_temp": 55, + "weight_rain": 25, + "weight_wind": 10, + "weight_humidity": 0, + "weight_air": 5, + "weight_time": 5, + "factor_rules": { + "temp": { + "type": "lower", + "zero": 18, + "full": 0 + }, + "rain": { + "dir": "dry" + }, + "wind": { + "type": "strong" + }, + "humidity": { + "type": "ignore" + }, + "time": { + "type": "fixed", + "value": 100 + } + }, + "zero_rules": [], + "limit_description": "군밤 노점이 있는지는 반영하지 못해요", + "sentences": {}, + "sort_order": 27 } ] \ No newline at end of file diff --git a/backend/services/calc/index_calc.py b/backend/services/calc/index_calc.py index b16c348..2d4f99f 100644 --- a/backend/services/calc/index_calc.py +++ b/backend/services/calc/index_calc.py @@ -70,6 +70,10 @@ def temp_score(rule: dict, feels: float) -> tuple[int, str]: if rule["type"] == "range": lo, hi = rule["lo"], rule["hi"] return _peak(t, lo, hi, rule.get("best"), 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)) + return _clamp(30 + 7 * dist), f"{shown}, 편한 범위 {lo}~{hi}°에서 멀수록 올라가요" return _linear(t, rule["zero"], rule["full"]), shown diff --git a/backend/tests/test_feed.py b/backend/tests/test_feed.py index 6f65743..6251d94 100644 --- a/backend/tests/test_feed.py +++ b/backend/tests/test_feed.py @@ -43,7 +43,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"]) == 23 + assert len(body["stories"]) == 27 weather = next(p for p in body["posts"] if p["post_type"] == PostType.WEATHER.value) assert [s["kind"] for s in weather["slides"]] == ["hours", "rows"] assert len(weather["slides"][0]["hours"]) == 8 diff --git a/backend/tests/test_index_api.py b/backend/tests/test_index_api.py index 3f3f268..36e9ee0 100644 --- a/backend/tests/test_index_api.py +++ b/backend/tests/test_index_api.py @@ -39,11 +39,11 @@ def fakes(monkeypatch): @pytest.mark.anyio -async def test_index_list_ranks_all_23_with_3_day_trend(fakes): +async def test_index_list_ranks_all_27_with_3_day_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"]) == 23 and len(body["top3"]) == 3 + assert len(body["items"]) == 27 and len(body["top3"]) == 3 scores = [i["score"] for i in body["items"]] assert scores == sorted(scores, reverse=True) assert all(len(i["trend"]) == 3 for i in body["items"]) diff --git a/backend/tests/test_index_calc.py b/backend/tests/test_index_calc.py index 3632527..506efd4 100644 --- a/backend/tests/test_index_calc.py +++ b/backend/tests/test_index_calc.py @@ -47,6 +47,13 @@ def test_temp_peaks_at_best_and_loses_8_per_degree_outside(): assert temp_score({"type": "range", "lo": 10, "hi": 20, "offset": -6}, 21)[1].startswith("정상 15°") +def test_temp_away_rises_outside_comfort(): + rule = {"type": "away", "lo": 15, "hi": 24} + assert temp_score(rule, 20)[0] == 30 + assert temp_score(rule, 34)[0] == 100 + assert temp_score(rule, 5)[0] == 100 + + def test_rain_dry_and_wet(): assert rain_score({"dir": "dry"}, 30, False)[0] == 70 assert rain_score({"dir": "dry"}, 30, True)[0] == 0 diff --git a/frontend/public/icons/baseball.png b/frontend/public/icons/baseball.png new file mode 100644 index 0000000..910fcca Binary files /dev/null and b/frontend/public/icons/baseball.png differ diff --git a/frontend/public/icons/chestnut.png b/frontend/public/icons/chestnut.png new file mode 100644 index 0000000..89eb360 Binary files /dev/null and b/frontend/public/icons/chestnut.png differ diff --git a/frontend/public/icons/netflix.png b/frontend/public/icons/netflix.png new file mode 100644 index 0000000..96c5a2c Binary files /dev/null and b/frontend/public/icons/netflix.png differ diff --git a/frontend/public/icons/study.png b/frontend/public/icons/study.png new file mode 100644 index 0000000..94855ec Binary files /dev/null and b/frontend/public/icons/study.png differ diff --git a/frontend/src/b/lib.ts b/frontend/src/b/lib.ts index 33a51a9..01104d5 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']) +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']) const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf']) /** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons) */