Phase 2.1: Card mirror system for deckbuilding features
- Created MtgCardMirror and DeckCardLink models in mirror_models.py - Created card_mirror_service.py with sync_mirrors functionality - Added sync_mirrors() method to mtgjson_manager.py - Added mirror_get_db() dependency to database.py - Added DecklistFile.status column (DRAUGHT/FINAL) - Updated DeckCreate schema with status field - Added DeckWithCardsResponse schema with card_count - Updated deck router to query card mirrors and return card counts - Added plain text deck content support
This commit is contained in:
@@ -40,13 +40,9 @@ mtg_async_session = async_sessionmaker(
|
||||
expire_on_commit=False,
|
||||
)
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
"""Base class for all ORM models."""
|
||||
pass
|
||||
|
||||
|
||||
__all__ = ["Base", "get_db", "async_session", "engine", "mtg_get_db", "mtg_async_session", "mtg_engine"]
|
||||
# Mirror engine (same as primary — mirrors live in mtgo_platform)
|
||||
mirror_engine = engine
|
||||
mirror_async_session = async_session
|
||||
|
||||
|
||||
async def get_db() -> AsyncSession:
|
||||
@@ -73,3 +69,35 @@ async def mtg_get_db() -> AsyncSession:
|
||||
raise
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
|
||||
async def mirror_get_db() -> AsyncSession:
|
||||
"""FastAPI dependency that provides a database session for mirror operations."""
|
||||
async with mirror_async_session() as session:
|
||||
try:
|
||||
yield session
|
||||
await session.commit()
|
||||
except Exception:
|
||||
await session.rollback()
|
||||
raise
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
"""Base class for all ORM models."""
|
||||
pass
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Base",
|
||||
"get_db",
|
||||
"async_session",
|
||||
"engine",
|
||||
"mtg_get_db",
|
||||
"mtg_async_session",
|
||||
"mtg_engine",
|
||||
"mirror_get_db",
|
||||
"mirror_async_session",
|
||||
"mirror_engine",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user