mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 16:25:03 -05:00
Implement sorting for smart playlists queries
This will be used by the Title view in Remote.
This commit is contained in:
parent
ac427025b5
commit
20486ee0dd
18
src/db.c
Normal file → Executable file
18
src/db.c
Normal file → Executable file
@ -817,6 +817,7 @@ db_build_query_plitems_smart(struct query_params *qp, char *smartpl_query, char
|
|||||||
char *count;
|
char *count;
|
||||||
char *filter;
|
char *filter;
|
||||||
char *idx;
|
char *idx;
|
||||||
|
char *sort;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (qp->filter)
|
if (qp->filter)
|
||||||
@ -846,7 +847,22 @@ db_build_query_plitems_smart(struct query_params *qp, char *smartpl_query, char
|
|||||||
if (!idx)
|
if (!idx)
|
||||||
idx = "";
|
idx = "";
|
||||||
|
|
||||||
query = sqlite3_mprintf("SELECT * FROM files WHERE disabled = 0 AND %s AND %s %s;", smartpl_query, filter, idx);
|
switch (qp->sort)
|
||||||
|
{
|
||||||
|
case S_NONE:
|
||||||
|
sort = "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_NAME:
|
||||||
|
sort = "ORDER BY title ASC";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_ALBUM:
|
||||||
|
sort = "ORDER BY track ASC, album ASC";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
query = sqlite3_mprintf("SELECT * FROM files WHERE disabled = 0 AND %s AND %s %s %s;", smartpl_query, filter, sort, idx);
|
||||||
if (!query)
|
if (!query)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user