guideCity/backend/app/models/place.py
vrubelroman ca28c93daf Add researched Moscow seed content (22 places, RU/EN, 3 lengths)
Gorky Park (6), Red Square area (10), and Moscow-City (6) landmarks
with real historical/architectural facts, each with short/medium/long
narration text in Russian and English. Widened built_year to
varchar(128) since several entries need more than a bare year (e.g.
demolition/reconstruction ranges).

Verified end-to-end against the live backend: all 22 places load via
seed_loader, nearby search returns correctly distance-sorted results
with radius expansion in sparser areas (confirmed at Gorky Park,
900m), and place detail/search-fallback endpoints return full
bilingual content. Full pytest suite passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 18:41:16 +00:00

38 lines
1.7 KiB
Python

from datetime import datetime
from geoalchemy2 import Geography
from sqlalchemy import Boolean, DateTime, Enum, ForeignKey, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.db.base import Base
from app.models.enums import PlaceCategory
class Place(Base):
__tablename__ = "places"
id: Mapped[int] = mapped_column(primary_key=True)
city_id: Mapped[int] = mapped_column(ForeignKey("cities.id", ondelete="CASCADE"), nullable=False)
slug: Mapped[str] = mapped_column(String(128), unique=True, nullable=False)
category: Mapped[PlaceCategory] = mapped_column(
Enum(PlaceCategory, name="place_category", native_enum=True), nullable=False
)
location = mapped_column(
Geography(geometry_type="POINT", srid=4326, spatial_index=False), nullable=False
)
address: Mapped[str | None] = mapped_column(String(256))
district: Mapped[str | None] = mapped_column(String(128))
built_year: Mapped[str | None] = mapped_column(String(128))
architect_builder: Mapped[str | None] = mapped_column(String(256))
architectural_style: Mapped[str | None] = mapped_column(String(128))
notable_people: Mapped[str | None] = mapped_column(Text)
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
)
city: Mapped["City"] = relationship(back_populates="places")
contents: Mapped[list["PlaceContent"]] = relationship(
back_populates="place", cascade="all, delete-orphan"
)