diff --git a/src/SMARTPL.g b/src/SMARTPL.g index aac59fdc..4fc76753 100644 --- a/src/SMARTPL.g +++ b/src/SMARTPL.g @@ -101,6 +101,7 @@ DATETAG : 'time_added' | 'time_modified' | 'time_played' | 'time_skipped' + | 'date_released' ; ENUMTAG : 'data_kind' diff --git a/src/db.c b/src/db.c index bcb5927d..3743a360 100644 --- a/src/db.c +++ b/src/db.c @@ -426,6 +426,7 @@ static const char *sort_clause[] = "f.virtual_path COLLATE NOCASE", "pos", "shuffle_pos", + "f.date_released DESC, f.title_sort DESC", }; /* Browse clauses, used for SELECT, WHERE, GROUP BY and for default ORDER BY diff --git a/src/db.h b/src/db.h index db0c9496..e1c52604 100644 --- a/src/db.h +++ b/src/db.h @@ -30,6 +30,7 @@ enum sort_type { S_VPATH, S_POS, S_SHUFFLE_POS, + S_DATE_RELEASED, }; #define Q_F_BROWSE (1 << 15) diff --git a/src/db_init.c b/src/db_init.c index e1b62bea..206c38f9 100644 --- a/src/db_init.c +++ b/src/db_init.c @@ -335,6 +335,9 @@ static const struct db_init_query db_init_table_queries[] = #define I_FILE_DIR \ "CREATE INDEX IF NOT EXISTS idx_file_dir ON files(disabled, directory_id);" +#define I_DATE_RELEASED \ + "CREATE INDEX IF NOT EXISTS idx_date_released ON files(disabled, date_released DESC, media_kind);" + #define I_PL_PATH \ "CREATE INDEX IF NOT EXISTS idx_pl_path ON playlists(path);" @@ -384,6 +387,7 @@ static const struct db_init_query db_init_index_queries[] = { I_ALBUM, "create album index" }, { I_FILELIST, "create filelist index" }, { I_FILE_DIR, "create file dir index" }, + { I_DATE_RELEASED, "create date_released index" }, { I_PL_PATH, "create playlist path index" }, { I_PL_DISABLED, "create playlist state index" }, diff --git a/src/db_init.h b/src/db_init.h index 8c9c0996..a20eeb96 100644 --- a/src/db_init.h +++ b/src/db_init.h @@ -26,7 +26,7 @@ * is a major upgrade. In other words minor version upgrades permit downgrading * forked-daapd after the database was upgraded. */ #define SCHEMA_VERSION_MAJOR 21 -#define SCHEMA_VERSION_MINOR 02 +#define SCHEMA_VERSION_MINOR 03 int db_init_indices(sqlite3 *hdl); diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 07f5275e..1c6472e5 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -573,7 +573,7 @@ query_params_set(struct query_params *qp, int *sort_headers, struct httpd_reques else if (strcmp(param, "artist") == 0 && (type != Q_BROWSE_ARTISTS)) // Only set if non-default sort requested qp->sort = S_ARTIST; else if (strcmp(param, "releasedate") == 0) - qp->sort = S_NAME; + qp->sort = S_DATE_RELEASED; else DPRINTF(E_DBG, L_DAAP, "Unknown sort param: %s\n", param);