mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Add video count to playlists response.
This commit is contained in:
parent
12ccec3c4e
commit
c10ff6e3c5
1 changed files with 8 additions and 1 deletions
|
@ -1368,12 +1368,19 @@ public class ResponseHelper {
|
||||||
|
|
||||||
var playlists = new ObjectArrayList<>();
|
var playlists = new ObjectArrayList<>();
|
||||||
|
|
||||||
for (var playlist : user.getPlaylists()) {
|
// Select user playlists and count the number of videos in each playlist
|
||||||
|
var query = s.createQuery("SELECT p, COUNT(v) FROM Playlist p LEFT JOIN p.videos v WHERE p.owner = :owner GROUP BY p.id", Object[].class);
|
||||||
|
query.setParameter("owner", user);
|
||||||
|
for (Object[] row : query.list()) {
|
||||||
|
var playlist = (me.kavin.piped.utils.obj.db.Playlist) row[0];
|
||||||
|
var videoCount = (long) row[1];
|
||||||
|
|
||||||
ObjectNode node = mapper.createObjectNode();
|
ObjectNode node = mapper.createObjectNode();
|
||||||
node.put("id", String.valueOf(playlist.getPlaylistId()));
|
node.put("id", String.valueOf(playlist.getPlaylistId()));
|
||||||
node.put("name", playlist.getName());
|
node.put("name", playlist.getName());
|
||||||
node.put("shortDescription", playlist.getShortDescription());
|
node.put("shortDescription", playlist.getShortDescription());
|
||||||
node.put("thumbnail", rewriteURL(playlist.getThumbnail()));
|
node.put("thumbnail", rewriteURL(playlist.getThumbnail()));
|
||||||
|
node.put("videos", videoCount);
|
||||||
playlists.add(node);
|
playlists.add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue