Add tags filter to ORM.getMediaFilesWhere

This commit is contained in:
Jonathan Bernard 2016-03-08 10:39:57 -06:00
parent 99c883dbe5
commit 710083131a

View File

@ -410,6 +410,16 @@ public class ORM {
query.append("mf.file_hash = ?"
sqlParams << params.fileHash }
if (params.tags) {
String L = "mft${idx}":
String T = "t${idx}":
tags.eachWithIndex { tag, idx ->
query.append(" JOIN media_files_tags $L ON ")
.append(" $L.media_file_id = md.id ")
.append(" JOIN tags $L.tag_id = $T.id AND $T.name = ?")
sqlParams << tag } }
if (whereClauses)
query.append(" WHERE ").append(whereClauses.join(" AND ")