Skip to content

Commit

Permalink
Order albums by addition time descending
Browse files Browse the repository at this point in the history
  • Loading branch information
m-danya committed Apr 2, 2024
1 parent 86ac8ff commit d82a173
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion accompanist/collection/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class AlbumDAO(BaseDAO):
@classmethod
async def get_all(cls) -> list[dict]:
async with async_session_maker() as session:
query = select(cls.model).options(selectinload(Album.artist))
query = (
select(Album)
.options(selectinload(Album.artist))
.order_by(Album.added_at.desc())
)
result = await session.execute(query)
albums = result.scalars().all()
return [album.to_json() for album in albums]
Expand Down

0 comments on commit d82a173

Please sign in to comment.