Added ordering logic to media file selection criteria.
This commit is contained in:
parent
13b0fa5bc4
commit
a4013ed365
@ -353,6 +353,7 @@ public class ORM {
|
||||
public List<MediaFile> getMediaFilesWhere(Map params) {
|
||||
def query = new StringBuilder()
|
||||
def sqlParams = []
|
||||
def orderClauses = [] as LinkedList
|
||||
|
||||
query.append("SELECT mf.* FROM media_files mf ")
|
||||
|
||||
@ -360,18 +361,23 @@ public class ORM {
|
||||
query.append(" JOIN artists_media_files armf ON ")
|
||||
.append(" mf.id = armf.media_file_id ")
|
||||
query.append(" AND armf.artist_id = ? ")
|
||||
sqlParams << params.artistId }
|
||||
sqlParams << params.artistId
|
||||
orderClauses << "armf.artist_id" }
|
||||
|
||||
if (params.albumId) {
|
||||
query.append(" JOIN albums_media_files almf ON ")
|
||||
.append(" al.id = almf.album_id ")
|
||||
.append(" mf.id = almf.media_file_id ")
|
||||
.append(" mf.album_id = almf.album_id ")
|
||||
query.append(" AND almf.album_id = ? ")
|
||||
sqlParams << params.albumId }
|
||||
sqlParams << params.albumId
|
||||
orderClauses << "almf.album_id ASC"
|
||||
orderClauses << "mf.track_number ASC" }
|
||||
|
||||
if (params.playlistId) {
|
||||
query.append(" JOIN playlists_media_files pmf ON ")
|
||||
query.append(" pmf.media_file_id = mf.id AND ")
|
||||
query.append(" pmf.playlist_id = ?")
|
||||
orderClauses.addFirst("pmf.position")
|
||||
sqlParams << params.playlistId }
|
||||
|
||||
if (params.name || params.fileHash || params.filePath ||
|
||||
|
Loading…
Reference in New Issue
Block a user