feat: 각 점수를 아침·낮·저녁·밤 구간별로 — 지금 구간 점수로 순위, 구간이 안 겹치는 각은 순위·피드에서 빼고 목록 끝에

This commit is contained in:
minaChoi committed 2026-10-08 17:07:26 +09:00
1 parent ffc330d478
commit d6525f592c
12 files changed
+226 -40

No files matched your search

+8 -1
View File
@@ -1,6 +1,6 @@
from datetime import date
from sqlalchemy import func, select
from sqlalchemy import func, select, text
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.ext.asyncio import AsyncSession
@@ -34,6 +34,13 @@ class IndexCRUD:
stmt = select(func.min(IndexScore.computed_at)).where(IndexScore.region_code == region_code, IndexScore.score_date == day)
return await s.scalar(stmt)
async def has_unslotted(self, s: AsyncSession, region_code: str, day: date) -> bool:
"""그날 행 중 구간 점수가 비어 있는 행(구간 계산 전 행)이 있는지."""
stmt = select(IndexScore.index_id).where(
IndexScore.region_code == region_code, IndexScore.score_date == day, text("index_score.slots = '{}'::jsonb")
).limit(1)
return (await s.scalar(stmt)) is not None
async def upsert_scores(self, s: AsyncSession, rows: list[dict]) -> None:
if not rows:
return