From a26373669d6c9a585a1d79aafec4868de94b6c3c Mon Sep 17 00:00:00 2001 From: cwilvx Date: Mon, 21 Oct 2024 10:09:49 +0300 Subject: [PATCH] try: fix all fav tracks order --- app/api/favorites.py | 1 - app/db/userdata.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/api/favorites.py b/app/api/favorites.py index eeb5a3c7..52ea01ac 100644 --- a/app/api/favorites.py +++ b/app/api/favorites.py @@ -137,7 +137,6 @@ def get_favorite_tracks(query: GetAllOfTypeQuery): Others will return -1 """ tracks, total = FavoritesTable.get_fav_tracks(query.start, query.limit) - tracks.reverse() tracks = TrackStore.get_tracks_by_trackhashes([t.hash for t in tracks]) return {"tracks": serialize_tracks(tracks), "total": total} diff --git a/app/db/userdata.py b/app/db/userdata.py index 2a7d838c..a4a3f48c 100644 --- a/app/db/userdata.py +++ b/app/db/userdata.py @@ -221,7 +221,9 @@ class FavoritesTable(Base): result = cls.execute( select(cls) # .select_from(join(table, cls, field == cls.hash)) - .where(and_(cls.type == type, cls.userid == get_current_userid())).offset( + .where(and_(cls.type == type, cls.userid == get_current_userid())) + .order_by(cls.timestamp.desc()) + .offset( start ) # INFO: If start is 0, fetch all so we can get the total count