diff --git a/backend/app/main.py b/backend/app/main.py index 4748d0f..71b3a57 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -15,7 +15,7 @@ Mounts all consolidated routers and provides centralized configuration. """ import asyncio import logging -from typing import AsyncGenerator +from contextlib import asynccontextmanager from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware @@ -36,7 +36,8 @@ from app.core.logging import configure_logging logger = logging.getLogger(__name__) -def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: +@asynccontextmanager +async def lifespan(app: FastAPI): """Application lifespan events for startup and shutdown.""" config = get_config() diff --git a/backend/app/routers/games_router.py b/backend/app/routers/games_router.py index f640a1a..f0b6553 100644 --- a/backend/app/routers/games_router.py +++ b/backend/app/routers/games_router.py @@ -346,7 +346,7 @@ async def create_game( # Fetch players for response player_stmt = select(GamePlayer).where(GamePlayer.game_id == new_game.id) - player_result = await db.execute(player_result) + player_result = await db.execute(player_stmt) players = player_result.scalars().all() new_game.players = [GamePlayerResponse.model_validate(p) for p in players] diff --git a/backend/state.json b/backend/state.json index 1102246..29bee5b 100644 --- a/backend/state.json +++ b/backend/state.json @@ -1,5 +1,5 @@ { - "project_summary": "MTG Online backend API with FastAPI, SQLAlchemy, and SQLite. Phase 5 development complete with all 28 tests passing.", + "project_summary": "MTG Online backend API with FastAPI, SQLAlchemy, and SQLite. Phase 5 development complete with all tests passing.", "roadmap": [ {"phase": "Phase 1-4", "status": "completed"}, {"phase": "Phase 5 - Game Management", "status": "completed"}, @@ -14,21 +14,19 @@ }, "architectural_notes": "Single-process FastAPI app with async SQLAlchemy. SQLite for development/testing. JWT auth with user roles.", "task_description": "Fix remaining game model test failures", - "current_step": "All 28 tests passing", + "current_step": "All tests passing", "files_created": [], "files_modified": [ "app/models/models.py" ], "decisions": [ - "Use execution_options for implicit_returning in SQLAlchemy 2.0", - "Use datetime.now instead of func.now() for async serialization", - "Use lazy='selectin' for async-safe relationship loading", - "Add host_id field to GameHistory model" + "Added host_id field to GameHistory model", + "Changed players relationship to lazy='selectin' for async compatibility" ], "next_steps": [ - "Phase 6 - WebSocket Game Server" + "Phase 6: WebSocket game server development" ], "blockers": [], - "commit_hash": "f7d6bfd", - "timestamp": "2026-10-18T04:02:00Z" + "commit_hash": "3926b57", + "timestamp": "2026-10-18T13:08:00Z" } \ No newline at end of file