feat: 데이트 명소를 전국 TourAPI 2,435곳으로 채우고 구 중심 30km 거리 기준으로 고르기

This commit is contained in:
minaChoi committed 2026-10-08 09:03:48 +09:00
1 parent e8382f450b
commit 87055a73dc
16 files changed
+2659 -47

No files matched your search

+8 -4
View File
@@ -26,14 +26,18 @@ class WeekCRUD:
if rows:
await s.execute(insert(Holiday).values(rows).on_conflict_do_nothing(index_elements=["holiday_date", "name"]))
async def places(self, s: AsyncSession, sido_code: str) -> list[Place]:
stmt = select(Place).where(Place.region_code.startswith(sido_code)).order_by(Place.sort_order)
async def places_in_box(self, s: AsyncSession, lat: float, lon: float, dlat: float, dlon: float) -> list[Place]:
stmt = select(Place).where(Place.lat.between(lat - dlat, lat + dlat), Place.lon.between(lon - dlon, lon + dlon))
return list((await s.scalars(stmt)).all())
async def all_places(self, s: AsyncSession) -> list[Place]:
return list((await s.scalars(select(Place).where(Place.lat.is_not(None)))).all())
async def replace_places(self, s: AsyncSession, rows: list[dict]) -> None:
await s.execute(delete(Place))
if rows:
await s.execute(insert(Place).values(rows))
# asyncpg 는 한 문장에 인자 32767개까지라 나눠 넣는다.
for i in range(0, len(rows), 1000):
await s.execute(insert(Place).values(rows[i:i + 1000]))
async def events(self, s: AsyncSession, sido_codes: list[str], since: date, until: date) -> list[Event]:
stmt = select(Event).where(Event.sido_code.in_(sido_codes), Event.end_date >= since, Event.start_date <= until)