mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Simplify and optimize playlist query.
This commit is contained in:
parent
d6bfc8f9ae
commit
8d23459406
1 changed files with 4 additions and 9 deletions
|
@ -142,15 +142,10 @@ public class DatabaseHelper {
|
||||||
CriteriaBuilder cb = s.getCriteriaBuilder();
|
CriteriaBuilder cb = s.getCriteriaBuilder();
|
||||||
CriteriaQuery<PlaylistVideo> cr = cb.createQuery(PlaylistVideo.class);
|
CriteriaQuery<PlaylistVideo> cr = cb.createQuery(PlaylistVideo.class);
|
||||||
var root = cr.from(PlaylistVideo.class);
|
var root = cr.from(PlaylistVideo.class);
|
||||||
root.fetch("channel", JoinType.RIGHT);
|
|
||||||
cr.select(root);
|
cr.select(root);
|
||||||
var sq = cr.subquery(String.class);
|
root.fetch("channel", JoinType.LEFT);
|
||||||
{
|
var plRoot = cr.from(Playlist.class);
|
||||||
var sqRoot = sq.from(Playlist.class);
|
cr.where(cb.equal(plRoot.get("playlist_id"), UUID.fromString(id)));
|
||||||
sq.select(sqRoot.get("videos").get("id"))
|
|
||||||
.where(cb.equal(sqRoot.get("playlist_id"), UUID.fromString(id)));
|
|
||||||
}
|
|
||||||
cr.where(root.get("id").in(sq));
|
|
||||||
|
|
||||||
return s.createQuery(cr).list();
|
return s.createQuery(cr).list();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue