[preset] GO

This commit is contained in:
doman 2023-10-27 17:23:21 +02:00
parent 9a84abc0ad
commit 3fd0a76975

View file

@ -87,12 +87,10 @@ class Preset(Base, CommonMixin):
limit: int,
q: Optional[str] = None,
) -> AsyncIterator["Preset"]:
query = select(cls)
query = select(cls).filter(cls.user_id == user_id)
if q:
query = query.filter(cls.user_id == user_id).filter(
cls.name.ilike(f"%{q.lower()}%")
)
query = query.filter(cls.name.ilike(f"%{q.lower()}%"))
query = query.offset(offset).limit(limit)
stream = await session.stream_scalars(query.order_by(cls.id))