Fix SQL query for tag filtering

This commit is contained in:
Martin Müller 2018-01-17 01:55:21 +01:00
parent b0df58c925
commit 8765fbb360

View File

@ -170,10 +170,10 @@ WHERE button.id IN (
GROUP BY button_tags.fk_button
HAVING
"""
tagFilter = "\t\tSUM(CASE WHEN tag.name = \"{}\" THEN 1 ELSE 0 END) > 0"
tagFilter = "\t\tSUM(CASE WHEN tag.name = ? THEN 1 ELSE 0 END) > 0"
tagFilters = " AND \n".join([tagFilter.format(tag) for tag in tags.split(",")])
query += tagFilters + "\n)"
sounds = queryDB(query)
sounds = queryDB(query, tags.split(","))
return jsonify([sound["file"].split(".")[0] for sound in sounds])