feat: Open-Meteo 구름 20·100km 구 코드 저장, 보조값 수집, 활동 지수 10개에 자외선·햇빛·가시거리 반영

구름
- 노을·일출 점수를 구 중심 20·100km 두 지점으로 계산 (50km 제외), 모델은 JMA·ICON 두 개만 사용
- cloud_hourly를 (구 코드, 방향, 거리, 시각, 모델) 키로 바꾸고 점수에 쓰는 시각만 저장

보조값
- openmeteo_hourly 신규: 자외선·가시거리·돌풍·기압·지표면 온도(끝 시각 값), 일조(3시간 합), 일사(평균·최대)
- worker가 03·09·15·21시 10분에 구 256곳을 요청 11번으로 일괄 수집, 7일 지난 행 정리
- 새 응답에서 값이 비어 오면 이전 값을 유지(COALESCE)

지수
- 새 축 uv·sun·view 추가 (index_definition/index_score 칼럼, 비중 있는 지수에만 상세에 표시)
- 빨래·멍뭉산책·피크닉·등산·러닝·가드닝·별보기·사진산책에 비중 배분, 자전거·캠핑·멍뭉산책에 돌풍·지표면 온도 0점 조건
- 자외선·가시거리 등 순간값은 가장 가까운 3시간 구간, 일조는 덮는 구간을 계산 창에 연결
- 보조값이 새로 오면 지수를 다시 계산하도록 재계산 기준에 fetched_at 추가

테스트 102개 통과 (PGSSLMODE=disable, JWT는 테스트용 환경변수).
This commit is contained in:
skkim committed 2026-10-06 17:21:59 +09:00
1 parent 7244449b7a
commit 7c12651068
19 files changed
+712 -82

No files matched your search

+26 -2
View File
@@ -99,8 +99,9 @@ class WeatherWarning(Base):
class CloudHourly(Base):
__tablename__ = "cloud_hourly"
lat: Mapped[Decimal] = mapped_column(Numeric(5, 2), primary_key=True)
lon: Mapped[Decimal] = mapped_column(Numeric(5, 2), primary_key=True)
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
kind: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
distance_km: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
forecast_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), primary_key=True)
model: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
cloud_low: Mapped[int] = mapped_column(SmallInteger)
@@ -108,6 +109,23 @@ class CloudHourly(Base):
cloud_high: Mapped[int] = mapped_column(SmallInteger)
class OpenMeteoHourly(Base):
__tablename__ = "openmeteo_hourly"
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
forecast_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), primary_key=True)
uv_index: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 2), nullable=True)
uv_index_clear_sky: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 2), nullable=True)
visibility_m: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
wind_gust_ms: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
pressure_hpa: Mapped[Optional[Decimal]] = mapped_column(Numeric(5, 1), nullable=True)
soil_temp_c: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
sunshine_s: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
shortwave_avg_wm2: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
shortwave_max_wm2: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
fetched_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
class SkyScore(Base):
__tablename__ = "sky_score"
@@ -151,6 +169,9 @@ class IndexDefinition(Base):
weight_wind: Mapped[int] = mapped_column(SmallInteger)
weight_humidity: Mapped[int] = mapped_column(SmallInteger)
weight_air: Mapped[int] = mapped_column(SmallInteger)
weight_uv: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
weight_sun: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
weight_view: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
weight_time: Mapped[int] = mapped_column(SmallInteger)
factor_rules: Mapped[dict] = mapped_column(JSONB)
zero_rules: Mapped[list] = mapped_column(JSONB)
@@ -172,6 +193,9 @@ class IndexScore(Base):
wind_score: Mapped[int] = mapped_column(SmallInteger)
humidity_score: Mapped[int] = mapped_column(SmallInteger)
air_score: Mapped[int] = mapped_column(SmallInteger)
uv_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
sun_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
view_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
time_score: Mapped[int] = mapped_column(SmallInteger)
zero_reason: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
notes: Mapped[dict] = mapped_column(JSONB)