Refactor: Next.js+Firebase → React(Vite) + FastAPI + PostgreSQL
- 백엔드: FastAPI + SQLAlchemy(async) + PostgreSQL, 별도 워커(APScheduler) - 프론트: React 19 + Vite + TS + Tailwind v4 (기존 UI 이식, API 연동) - docker-compose: db · api · worker · frontend 일괄 실행 - 경기 일정: openfootball 매일 09:00 크롤링 → DB upsert (신규 경기 자동 삽입+예측 생성) - AI 예측: GPT·Claude·Gemini 실 API 매일 생성 → DB 저장 → 조회 (목데이터 제거) - 투표창: 오픈 킥오프 D-2 / 마감 킥오프 1시간 전, lockAt 백엔드 전달→프론트 카운트다운 - 채점/리더보드: docs/SCORING.md 기준 누적 포인트 - crowd: 0 시작, 실제 제출로만 증분 - 구 Next.js/Firebase 파일 제거, README/AGENTS 갱신 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
35414a8d47
commit
6ffe0dfca3
95 files changed
+5266
-8856
No files matched your search
@@ -0,0 +1,63 @@
|
||||
"""DB 시드 — 경기 6개 + AI 예측(부트스트랩) + crowd baseline.
|
||||
|
||||
init_db 직후 호출. 이미 경기가 있으면 건너뛴다(idempotent).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from .database import SessionLocal
|
||||
from .models import CrowdStats, Match
|
||||
from .schedule_data import GROUP_A, lock_at, opens_at, parse_kickoff, TEAMS
|
||||
from .seed_data import generate_crowd
|
||||
|
||||
log = logging.getLogger("triplepick.seed")
|
||||
|
||||
|
||||
async def seed_if_empty() -> None:
|
||||
async with SessionLocal() as db:
|
||||
existing = (await db.execute(select(Match.match_id))).scalars().first()
|
||||
if existing:
|
||||
log.info("seed: matches already present — skip")
|
||||
return
|
||||
|
||||
for s in GROUP_A:
|
||||
kickoff = parse_kickoff(s.kickoff_iso)
|
||||
ta, tb = TEAMS[s.team_a], TEAMS[s.team_b]
|
||||
match = Match(
|
||||
match_id=s.match_id,
|
||||
round_label=s.round_label,
|
||||
group="A",
|
||||
team_a_name=ta["name"],
|
||||
team_a_short=ta["shortName"],
|
||||
team_a_code=ta["code"],
|
||||
team_a_flag=ta["flag"],
|
||||
team_b_name=tb["name"],
|
||||
team_b_short=tb["shortName"],
|
||||
team_b_code=tb["code"],
|
||||
team_b_flag=tb["flag"],
|
||||
venue=s.venue,
|
||||
hook_text=s.hook_text,
|
||||
kickoff_at=kickoff,
|
||||
opens_at=opens_at(kickoff),
|
||||
lock_at=lock_at(kickoff),
|
||||
status="scheduled",
|
||||
)
|
||||
db.add(match)
|
||||
|
||||
crowd = generate_crowd(s.match_id)
|
||||
db.add(
|
||||
CrowdStats(
|
||||
match_id=s.match_id,
|
||||
total=crowd["total"],
|
||||
team_a_win=crowd["teamAWin"],
|
||||
draw=crowd["draw"],
|
||||
team_b_win=crowd["teamBWin"],
|
||||
)
|
||||
)
|
||||
# AI 예측은 시드하지 않는다 — 워커가 실 API 로 생성.
|
||||
|
||||
await db.commit()
|
||||
log.info("seed: %d matches + crowd seeded (예측 없음 — 워커가 실 API 생성)", len(GROUP_A))
|
||||
Reference in new issue
Block a user