Add order_by to backend getting sense list
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## ToDo
|
## ToDo
|
||||||
|
|
||||||
1. Refactoring: create separate pages and user controls
|
1. Implement infinity scroll
|
||||||
2. Implement S3 backend client
|
2. Implement S3 backend client
|
||||||
3. Implement FTP backend client
|
3. Implement FTP backend client
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,11 @@ class DatabaseService(ServiceMixin):
|
|||||||
page: int = 1,
|
page: int = 1,
|
||||||
limit: int = 10,
|
limit: int = 10,
|
||||||
) -> list[Sense]:
|
) -> list[Sense]:
|
||||||
query = select(Sense).where(Sense.user == user).limit(limit).offset((page - 1) * limit)
|
query = (
|
||||||
|
select(Sense).where(Sense.user == user)
|
||||||
|
.order_by(Sense.created_at.desc())
|
||||||
|
.limit(limit).offset((page - 1) * limit)
|
||||||
|
)
|
||||||
|
|
||||||
result = await session.execute(query)
|
result = await session.execute(query)
|
||||||
senses = result.scalars().all()
|
senses = result.scalars().all()
|
||||||
|
|||||||
Reference in New Issue
Block a user