feat: 노을 점수 맑은 하늘 구간을 매끄럽게 하고 가시거리·습도·비 갠 뒤로 공기 보정
This commit is contained in:
1 parent
3c8e8984af
commit
0c168d1ffe
6 files changed
+144
-13
No files matched your search
@@ -4,7 +4,7 @@ from sqlalchemy import delete, select
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.database.model.models import CloudHourly, Region, SkyScore, SunsetSpot
|
||||
from common.database.model.models import CloudHourly, OpenMeteoHourly, Region, SkyScore, SunsetSpot, WeatherHourly
|
||||
|
||||
_CHUNK = 2000
|
||||
|
||||
@@ -44,5 +44,19 @@ class SkyCRUD:
|
||||
if rows:
|
||||
await s.execute(insert(SunsetSpot).values(rows))
|
||||
|
||||
async def hourly_for(self, s: AsyncSession, region_codes: list[str], start: datetime, end: datetime) -> list[WeatherHourly]:
|
||||
"""노을 공기 보정용 습도·비 확률 (단기예보 시간별)."""
|
||||
stmt = select(WeatherHourly).where(
|
||||
WeatherHourly.region_code.in_(region_codes), WeatherHourly.forecast_at >= start, WeatherHourly.forecast_at < end
|
||||
)
|
||||
return list((await s.scalars(stmt)).all())
|
||||
|
||||
async def openmeteo_for(self, s: AsyncSession, region_codes: list[str], start: datetime, end: datetime) -> list[OpenMeteoHourly]:
|
||||
"""노을 공기 보정용 가시거리 (Open-Meteo 3시간 구간)."""
|
||||
stmt = select(OpenMeteoHourly).where(
|
||||
OpenMeteoHourly.region_code.in_(region_codes), OpenMeteoHourly.forecast_at >= start, OpenMeteoHourly.forecast_at < end
|
||||
)
|
||||
return list((await s.scalars(stmt)).all())
|
||||
|
||||
async def ranking_regions(self, s: AsyncSession) -> list[Region]:
|
||||
return list((await s.scalars(select(Region).where(Region.is_ranking_spot.is_(True)))).all())
|
||||
Reference in new issue
Block a user