add item counts

This commit is contained in:
cwilvx
2025-04-22 09:37:11 +03:00
parent 76997ca3fa
commit 6eb70b7d7c
+3 -3
View File
@@ -123,15 +123,13 @@ def get_folder_tree(body: FolderTree):
reverse=True, reverse=True,
) )
for playlist in playlists:
playlist.clear_lists()
return { return {
"path": req_dir, "path": req_dir,
"folders": [ "folders": [
{ {
"name": p.name, "name": p.name,
"path": f"$playlist/{p.id}", "path": f"$playlist/{p.id}",
"trackcount": p.count,
} }
for p in playlists for p in playlists
], ],
@@ -172,11 +170,13 @@ def get_folder_tree(body: FolderTree):
playlists_item = { playlists_item = {
"name": "Playlists", "name": "Playlists",
"path": "$playlists", "path": "$playlists",
"trackcount": sum(p.count for p in PlaylistTable.get_all()),
} }
favorites_item = { favorites_item = {
"name": "Favorites", "name": "Favorites",
"path": "$favorites", "path": "$favorites",
"trackcount": FavoritesTable.get_fav_tracks(0, -1)[1],
} }
results["folders"].insert(0, playlists_item) results["folders"].insert(0, playlists_item)