From d6cedcdec7afb15df1cce86287613c397444f073 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 8 Oct 2026 09:22:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=85=B8=EC=9D=84=20=EB=AA=85=EC=86=8C?= =?UTF-8?q?=EA=B0=80=2030km=20=EC=95=88=EC=97=90=20=EC=97=86=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20=EA=B0=80=EC=9E=A5=20=EA=B0=80=EA=B9=8C=EC=9A=B4=20?= =?UTF-8?q?=ED=95=9C=20=EA=B3=B3=EC=9D=84=20=EA=B1=B0=EB=A6=AC=EC=99=80=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 +- backend/services/sky_service.py | 10 ++++++---- backend/tests/test_sky_api.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index b3b4f02..368ad29 100644 --- a/TODO.md +++ b/TODO.md @@ -36,7 +36,7 @@ | [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` | | [x] | 노을 명소 30km 안에 하나도 없는 구 89/256 — 광주·대전·세종·충북·강원·경북 내륙·전북 내륙 등. TourAPI 키워드로는 안 잡혀 직접 추가하거나 반경을 넓힐지 결정 필요 → 노을 근거를 확인한 21곳을 추가해 89 → 23 | 명소 확충 결과 | `backend/seed/sunset_spot.csv`, `backend/services/sky_service.py` | -| [ ] | 노을 명소 30km 안에 없는 구 23/256(최대 51.8km) — 강원 동해·삼척·양구·인제·태백·횡성, 경남 거창·산청·함양, 경북 구미·김천·봉화·안동·울진·의성, 대구 군위, 전남 곡성·구례, 전북 남원·임실·장수·진안, 충북 보은. 노을 근거를 찾지 못함. 반경 밖이면 화면엔 '근처에 등록된 노을 명소가 없어요'만 나오고 가장 가까운 곳·거리는 안 나옴 | 명소 보강 결과 | `backend/seed/sunset_spot.csv`, `backend/services/sky_service.py` (`nearest_spots`), `frontend/src/b/SkyPage.tsx` | +| [ ] | 노을 명소 30km 안에 없는 구 23/256(최대 51.8km, 지금은 가장 가까운 1곳을 거리와 함께 보여 줌) — 강원 동해·삼척·양구·인제·태백·횡성, 경남 거창·산청·함양, 경북 구미·김천·봉화·안동·울진·의성, 대구 군위, 전남 곡성·구례, 전북 남원·임실·장수·진안, 충북 보은. 노을 근거를 찾지 못함. 반경 밖이면 화면엔 '근처에 등록된 노을 명소가 없어요'만 나오고 가장 가까운 곳·거리는 안 나옴 | 명소 보강 결과 | `backend/seed/sunset_spot.csv`, `backend/services/sky_service.py` (`nearest_spots`), `frontend/src/b/SkyPage.tsx` | | [x] | 명소 '서쪽이 트임'(west_open)·설명 꼬리말은 TourAPI 개요를 보고 사람이 붙인 값 — 현장 확인 안 됨. 분당구는 가장 가까운 곳이 17~18km(일자산·반포·광나루)라 수도권 동남부 명소 보강 필요 → 화면에서 설명을 빼고 방향·거리만 보여줌. 현장 확인은 여전히 안 됨 | 명소 확충 결과 | `backend/seed/sunset_spot.csv` | | [ ] | TourAPI 좌표 오류로 뺀 곳: 기흥레스피아호수공원(용인)·급치산전망대(진도) — 좌표가 (19.69, 117.99). 좌표를 직접 넣어 추가할지 결정 | 명소 확충 결과 | `backend/seed/sunset_spot_tourapi.csv` | | [x] | 서울·경기 반영 범위 확인 — 서울 25구·경기 31시군(구 있는 시는 구 단위, 부천 3구·화성 4구 포함) 모두 있고 코드도 기상청 격자표(2607) 현행 코드와 일치 | 10/2 회의 확인 필요 | `backend/seed/region.csv` | diff --git a/backend/services/sky_service.py b/backend/services/sky_service.py index bf8f023..e963618 100644 --- a/backend/services/sky_service.py +++ b/backend/services/sky_service.py @@ -79,10 +79,12 @@ class RankItem: def nearest_spots(lat: float, lon: float, spots: list[SunsetSpot]) -> list[Spot]: - """반경 안에서 해 지는 쪽이 트인 곳(sort_order 0)을 먼저, 그 안에서는 가까운 순.""" - near = [Spot(spot=p, distance_km=round(haversine_km(lat, lon, float(p.lat), float(p.lon)), 1), direction=bearing_deg(lat, lon, float(p.lat), float(p.lon))) - for p in spots] - near = [x for x in near if x.distance_km <= SPOT_RADIUS_KM] + """반경 안에서 해 지는 쪽이 트인 곳(sort_order 0)을 먼저, 그 안에서는 가까운 순. 반경 안에 없으면 가장 가까운 한 곳.""" + every = [Spot(spot=p, distance_km=round(haversine_km(lat, lon, float(p.lat), float(p.lon)), 1), direction=bearing_deg(lat, lon, float(p.lat), float(p.lon))) + for p in spots] + near = [x for x in every if x.distance_km <= SPOT_RADIUS_KM] + if not near: + return sorted(every, key=lambda x: x.distance_km)[:1] return sorted(near, key=lambda x: (x.spot.sort_order, x.distance_km))[:SPOT_LIMIT] diff --git a/backend/tests/test_sky_api.py b/backend/tests/test_sky_api.py index 6acc19b..6881b3a 100644 --- a/backend/tests/test_sky_api.py +++ b/backend/tests/test_sky_api.py @@ -93,7 +93,7 @@ async def test_sky_spots_by_distance(monkeypatch, clean, region, expected): assert [s["distance_km"] for s in spots] == sorted(s["distance_km"] for s in spots) -def test_nearest_spots_west_first_and_empty_outside_radius(): +def test_nearest_spots_west_first_and_nearest_one_outside_radius(): from decimal import Decimal from common.database.model.models import SunsetSpot @@ -103,7 +103,7 @@ def test_nearest_spots_west_first_and_empty_outside_radius(): spots = [spot("가까운 동쪽", 37.01, False), spot("먼 서쪽", 37.1, True), spot("반경 밖", 37.5, True)] assert [x.spot.name for x in sky_service.nearest_spots(37.0, 127.0, spots)] == ["먼 서쪽", "가까운 동쪽"] - assert sky_service.nearest_spots(33.0, 127.0, spots) == [] + assert [x.spot.name for x in sky_service.nearest_spots(36.0, 127.0, spots)] == ["가까운 동쪽"] def test_outlook_only_when_a_later_day_has_a_better_verdict():