allow limiting the number of listings fetched

This commit is contained in:
Viktor Barzin 2025-06-14 13:39:56 +00:00
parent 9b03ab83d2
commit ff2f141b75
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863

View file

@ -25,6 +25,7 @@ class ListingRepository:
self,
query_parameters: QueryParameters | None = None,
only_ids: list[int] | None = None,
limit: int | None = None,
) -> list[modelListing]:
"""
Get all listings from the database.
@ -37,6 +38,8 @@ class ListingRepository:
if only_ids:
query = query.where(RentListing.id.in_(only_ids)) # type: ignore
query = self._add_where_from_query_parameters(query, query_parameters)
if limit:
query = query.limit(limit)
with Session(self.engine) as session:
# query = select(modelListing)