Add listing decisions (like/dislike) backend with detail endpoint
- ListingDecision model with unique constraint on (user_id, listing_id, listing_type)
- Alembic migration for listingdecision table
- DecisionRepository with dialect-aware upsert (MySQL/SQLite)
- DecisionService with input validation
- Decision API routes: PUT/GET/DELETE on /api/decisions
- GET /api/listing/{id}/detail endpoint extracting full property info from additional_info
- Add listing ID to GeoJSON feature properties
- Decision filtering on GeoJSON stream endpoint (decision_filter param)
This commit is contained in:
parent
a2e7d59af2
commit
9e1beb7495
7 changed files with 447 additions and 138 deletions
49
alembic/versions/d7e8f9a0b1c2_add_listing_decision.py
Normal file
49
alembic/versions/d7e8f9a0b1c2_add_listing_decision.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"""add listing decision
|
||||
|
||||
Revision ID: d7e8f9a0b1c2
|
||||
Revises: c5d6e7f8a9b0
|
||||
Create Date: 2026-02-21 12:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'd7e8f9a0b1c2'
|
||||
down_revision: Union[str, None] = 'c5d6e7f8a9b0'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Create listingdecision table."""
|
||||
op.create_table('listingdecision',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('listing_id', sa.Integer(), nullable=False),
|
||||
sa.Column('listing_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('decision', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True,
|
||||
server_default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True,
|
||||
server_default=sa.func.now()),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id']),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user_id', 'listing_id', 'listing_type',
|
||||
name='uq_decision_user_listing_type'),
|
||||
)
|
||||
op.create_index(op.f('ix_listingdecision_user_id'),
|
||||
'listingdecision', ['user_id'], unique=False)
|
||||
op.create_index(op.f('ix_listingdecision_listing_id'),
|
||||
'listingdecision', ['listing_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Drop listingdecision table."""
|
||||
op.drop_index(op.f('ix_listingdecision_listing_id'), table_name='listingdecision')
|
||||
op.drop_index(op.f('ix_listingdecision_user_id'), table_name='listingdecision')
|
||||
op.drop_table('listingdecision')
|
||||
Loading…
Add table
Add a link
Reference in a new issue