Add services layer, tests, streaming UI, and cleanup legacy code

This commit is contained in:
Viktor Barzin 2026-02-06 20:55:10 +00:00
parent 5514fa6381
commit d205d15c74
62 changed files with 3729 additions and 1024 deletions

View file

@ -0,0 +1,56 @@
"""add streaming indexes for query optimization
Revision ID: a1b2c3d4e5f6
Revises: e5f1bc4e3323
Create Date: 2026-02-01 12:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
# revision identifiers, used by Alembic.
revision: str = 'a1b2c3d4e5f6'
down_revision: Union[str, None] = 'e5f1bc4e3323'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Add composite and single-column indexes for streaming query optimization."""
# Composite index for main query pattern (bedrooms, price, last_seen filtering)
op.create_index(
'ix_rentlisting_query_composite',
'rentlisting',
['number_of_bedrooms', 'price', 'last_seen'],
unique=False
)
op.create_index(
'ix_buylisting_query_composite',
'buylisting',
['number_of_bedrooms', 'price', 'last_seen'],
unique=False
)
# Missing single-column indexes for frequently filtered columns
op.create_index(
'ix_rentlisting_furnish_type',
'rentlisting',
['furnish_type'],
unique=False
)
op.create_index(
'ix_rentlisting_available_from',
'rentlisting',
['available_from'],
unique=False
)
def downgrade() -> None:
"""Remove streaming indexes."""
op.drop_index('ix_rentlisting_available_from', table_name='rentlisting')
op.drop_index('ix_rentlisting_furnish_type', table_name='rentlisting')
op.drop_index('ix_buylisting_query_composite', table_name='buylisting')
op.drop_index('ix_rentlisting_query_composite', table_name='rentlisting')

View file

@ -19,88 +19,12 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_user_email'), table_name='user')
op.drop_table('user')
op.drop_index(op.f('ix_rentlisting_last_seen'), table_name='rentlisting')
op.drop_index(op.f('ix_rentlisting_number_of_bedrooms'), table_name='rentlisting')
op.drop_index(op.f('ix_rentlisting_price'), table_name='rentlisting')
op.drop_index(op.f('ix_rentlisting_square_meters'), table_name='rentlisting')
op.drop_table('rentlisting')
op.drop_index(op.f('ix_buylisting_last_seen'), table_name='buylisting')
op.drop_index(op.f('ix_buylisting_number_of_bedrooms'), table_name='buylisting')
op.drop_index(op.f('ix_buylisting_price'), table_name='buylisting')
op.drop_index(op.f('ix_buylisting_square_meters'), table_name='buylisting')
op.drop_table('buylisting')
# ### end Alembic commands ###
"""Upgrade schema - this migration is now a no-op since tables already have correct column name."""
# The tables were created with 'longitude' (correct spelling) in the initial migration.
# This migration was incorrectly auto-generated and has been fixed to be a no-op.
pass
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('buylisting',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('price', mysql.FLOAT(), nullable=False),
sa.Column('number_of_bedrooms', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('square_meters', mysql.FLOAT(), nullable=True),
sa.Column('agency', mysql.VARCHAR(length=255), nullable=True),
sa.Column('council_tax_band', mysql.VARCHAR(length=255), nullable=True),
sa.Column('longtitude', mysql.FLOAT(), nullable=False),
sa.Column('latitude', mysql.FLOAT(), nullable=False),
sa.Column('price_history_json', mysql.TEXT(), nullable=False),
sa.Column('listing_site', mysql.ENUM('RIGHTMOVE'), nullable=False),
sa.Column('last_seen', mysql.DATETIME(), nullable=False),
sa.Column('photo_thumbnail', mysql.VARCHAR(length=255), nullable=True),
sa.Column('floorplan_image_paths', mysql.JSON(), nullable=False),
sa.Column('additional_info', mysql.JSON(), nullable=False),
sa.Column('routing_info_json', mysql.TEXT(), nullable=True),
sa.Column('service_charge', mysql.FLOAT(), nullable=True),
sa.Column('lease_left', mysql.INTEGER(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_index(op.f('ix_buylisting_square_meters'), 'buylisting', ['square_meters'], unique=False)
op.create_index(op.f('ix_buylisting_price'), 'buylisting', ['price'], unique=False)
op.create_index(op.f('ix_buylisting_number_of_bedrooms'), 'buylisting', ['number_of_bedrooms'], unique=False)
op.create_index(op.f('ix_buylisting_last_seen'), 'buylisting', ['last_seen'], unique=False)
op.create_table('rentlisting',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('price', mysql.FLOAT(), nullable=False),
sa.Column('number_of_bedrooms', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('square_meters', mysql.FLOAT(), nullable=True),
sa.Column('agency', mysql.VARCHAR(length=255), nullable=True),
sa.Column('council_tax_band', mysql.VARCHAR(length=255), nullable=True),
sa.Column('longtitude', mysql.FLOAT(), nullable=False),
sa.Column('latitude', mysql.FLOAT(), nullable=False),
sa.Column('price_history_json', mysql.TEXT(), nullable=False),
sa.Column('listing_site', mysql.ENUM('RIGHTMOVE'), nullable=False),
sa.Column('last_seen', mysql.DATETIME(), nullable=False),
sa.Column('photo_thumbnail', mysql.VARCHAR(length=255), nullable=True),
sa.Column('floorplan_image_paths', mysql.JSON(), nullable=False),
sa.Column('additional_info', mysql.JSON(), nullable=False),
sa.Column('routing_info_json', mysql.TEXT(), nullable=True),
sa.Column('available_from', mysql.DATETIME(), nullable=True),
sa.Column('furnish_type', mysql.ENUM('FURNISHED', 'UNFURNISHED', 'PART_FURNISHED', 'ASK_LANDLORD', 'UNKNOWN'), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_index(op.f('ix_rentlisting_square_meters'), 'rentlisting', ['square_meters'], unique=False)
op.create_index(op.f('ix_rentlisting_price'), 'rentlisting', ['price'], unique=False)
op.create_index(op.f('ix_rentlisting_number_of_bedrooms'), 'rentlisting', ['number_of_bedrooms'], unique=False)
op.create_index(op.f('ix_rentlisting_last_seen'), 'rentlisting', ['last_seen'], unique=False)
op.create_table('user',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('email', mysql.VARCHAR(length=255), nullable=False),
sa.Column('password', mysql.VARCHAR(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
# ### end Alembic commands ###
"""Downgrade schema - no-op since upgrade is no-op."""
pass