feat: add card import feature with fuzzy matching
- Add UserCardImport model (stores imported card names as JSON) - Create card_import_schemas.py with request/response models - Create card_import.py router with import/get/delete endpoints - Add Alembic migration 004 (user_card_imports table) - Fuzzy matching for card name matching (60% threshold) - Integration with deckbuilding via imported cards - Endpoints: GET /api/v1/card-import/status, POST /, DELETE /, GET /summary
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
SQLAlchemy ORM model for user card imports.
|
||||
|
||||
Stores a user's imported card collection as a JSON string containing
|
||||
a list of card names. This is the source data for building decks
|
||||
from the user's actual card collection.
|
||||
"""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class UserCardImport(Base):
|
||||
"""
|
||||
User's imported card collection.
|
||||
|
||||
Stores a JSON string of card names that the user owns.
|
||||
Used as the source for building decks from user's actual cards.
|
||||
"""
|
||||
__tablename__ = "user_card_imports"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id = Column(Integer, ForeignKey("mtgonline_users.id", ondelete="CASCADE"), nullable=False, unique=True, index=True)
|
||||
card_names_json = Column(Text, nullable=False) # JSON array of card names
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="card_imports")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<UserCardImport user={self.user_id}>"
|
||||
Reference in New Issue
Block a user