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:
@@ -25,6 +25,7 @@ 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
|
||||
|
||||
# this is the Alembic Config object
|
||||
config = context.config
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Alembic migration: Create user_card_imports table.
|
||||
|
||||
This migration adds the user_card_imports table which stores
|
||||
a user's imported card collection as a JSON array of card names.
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '004'
|
||||
down_revision = '003'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Create user_card_imports table."""
|
||||
op.create_table(
|
||||
'user_card_imports',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('card_names_json', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['mtgonline_users.id'], ondelete='CASCADE'),
|
||||
sa.UniqueConstraint('user_id', name='uq_user_card_imports_user_id'),
|
||||
sa.Index('idx_user_card_imports_user', 'user_id'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Drop user_card_imports table."""
|
||||
op.drop_table('user_card_imports')
|
||||
Reference in New Issue
Block a user