🚑️ /stop responses didn't return StopArea.stops fields
This commit is contained in:
@@ -23,6 +23,7 @@ from sqlalchemy.orm import (
|
|||||||
Mapped,
|
Mapped,
|
||||||
relationship,
|
relationship,
|
||||||
selectinload,
|
selectinload,
|
||||||
|
with_polymorphic,
|
||||||
)
|
)
|
||||||
from sqlalchemy.schema import Index
|
from sqlalchemy.schema import Index
|
||||||
from sqlalchemy_utils.types.ts_vector import TSVectorType
|
from sqlalchemy_utils.types.ts_vector import TSVectorType
|
||||||
@@ -98,11 +99,17 @@ class _Stop(Base):
|
|||||||
if (session := await cls.db.get_session()) is not None:
|
if (session := await cls.db.get_session()) is not None:
|
||||||
|
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
match_stmt = cls.names_tsv.match(name, postgresql_regconfig="french")
|
descendants = with_polymorphic(_Stop, "*")
|
||||||
ranking_stmt = func.ts_rank_cd(
|
|
||||||
cls.names_tsv, func.plainto_tsquery("french", name)
|
match_stmt = descendants.names_tsv.match(
|
||||||
|
name, postgresql_regconfig="french"
|
||||||
|
)
|
||||||
|
ranking_stmt = func.ts_rank_cd(
|
||||||
|
descendants.names_tsv, func.plainto_tsquery("french", name)
|
||||||
|
)
|
||||||
|
stmt = (
|
||||||
|
select(descendants).filter(match_stmt).order_by(desc(ranking_stmt))
|
||||||
)
|
)
|
||||||
stmt = select(cls).filter(match_stmt).order_by(desc(ranking_stmt))
|
|
||||||
|
|
||||||
res = await session.execute(stmt)
|
res = await session.execute(stmt)
|
||||||
stops = res.scalars().all()
|
stops = res.scalars().all()
|
||||||
|
Reference in New Issue
Block a user