Complete Phase 2: Card import, deck building, and full API
- Add card import feature with fuzzy matching - Implement deck CRUD and management endpoints - Add user data APIs for groups, networks, preferences, activity, replays - Create comprehensive API documentation (API_DOCUMENTATION.md) - Add ENDPOINT_AUDIT.md for endpoint verification - Update documentation (README, ROADMAP, state.json) - Update architecture blueprint and Cockatrice analysis - All Phase 2 deliverables complete and documented
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Models package
|
||||
"""Models package initialization."""
|
||||
from app.models.models import User, DecklistFile, DecklistFolder, Room, RoomGameType, Ban, GameLog, AuditLog
|
||||
from app.models.mtg_models import MtgSet, MtgCard
|
||||
from app.models.mirror_models import MtgCardMirror, DeckCardLink
|
||||
@@ -9,7 +9,8 @@ from app.models.user_data import (
|
||||
NetworkMember, UserPreference, UserActivityLog
|
||||
)
|
||||
from app.models.user_deck import UserDeck, UserDeckCard, DeckPrecedent, DeckPrecedentCard, CardSuggestion
|
||||
from app.models.user_card_import import UserCardImport
|
||||
from app.models.card_import_batch import CardImportBatch
|
||||
from app.models.user_card_import_record import UserCardImportRecord
|
||||
|
||||
__all__ = [
|
||||
"User",
|
||||
@@ -44,6 +45,6 @@ __all__ = [
|
||||
"DeckPrecedent",
|
||||
"DeckPrecedentCard",
|
||||
"CardSuggestion",
|
||||
"UserCardCollection",
|
||||
"UserCardImport",
|
||||
"CardImportBatch",
|
||||
"UserCardImportRecord",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
"""SQLAlchemy ORM model for card import batches."""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class CardImportBatch(Base):
|
||||
"""
|
||||
Card import batch record.
|
||||
|
||||
Tracks a single file import with its status and match results.
|
||||
"""
|
||||
__tablename__ = "card_import_batches"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id = Column(Integer, ForeignKey("mtgonline_users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
filename = Column(String(255), nullable=False)
|
||||
file_type = Column(String(10), nullable=False) # xlsx, csv, json, ods
|
||||
file_size = Column(Integer, nullable=False) # File size in bytes
|
||||
status = Column(String(20), nullable=False, default="pending", index=True) # pending, processing, completed, failed
|
||||
total_cards = Column(Integer, default=0)
|
||||
matched_cards = Column(Integer, default=0)
|
||||
unmatched_cards = Column(Integer, default=0)
|
||||
match_results = Column(JSON, nullable=True) # Store match results for later retrieval
|
||||
error_message = Column(Text, nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="import_batches")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<CardImportBatch id={self.id} user={self.user_id} status={self.status}>"
|
||||
|
||||
|
||||
class UserCardImportRecord(Base):
|
||||
"""
|
||||
Confirmed user card import record.
|
||||
|
||||
Stores the confirmed state of an imported card collection.
|
||||
"""
|
||||
__tablename__ = "user_card_imports_confirmed"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id = Column(Integer, ForeignKey("mtgonline_users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
batch_id = Column(Integer, ForeignKey("card_import_batches.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
is_confirmed = Column(Boolean, nullable=False, default=True)
|
||||
confirmed_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="confirmed_imports")
|
||||
batch = relationship("CardImportBatch", backref="confirmations")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<UserCardImportRecord id={self.id} user={self.user_id} confirmed={self.is_confirmed}>"
|
||||
@@ -0,0 +1,27 @@
|
||||
"""SQLAlchemy ORM model for confirmed card imports."""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class UserCardImportRecord(Base):
|
||||
"""
|
||||
Confirmed user card import record.
|
||||
|
||||
Stores the confirmed state of an imported card collection.
|
||||
"""
|
||||
__tablename__ = "user_card_imports_confirmed"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id = Column(Integer, ForeignKey("mtgonline_users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
batch_id = Column(Integer, ForeignKey("card_import_batches.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
is_confirmed = Column(Boolean, nullable=False, default=True)
|
||||
confirmed_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="confirmed_imports")
|
||||
batch = relationship("CardImportBatch", backref="confirmations")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<UserCardImportRecord id={self.id} user={self.user_id} confirmed={self.is_confirmed}>"
|
||||
Reference in New Issue
Block a user