diff --git a/src/db.c b/src/db.c index 5412c9fb..327a100b 100644 --- a/src/db.c +++ b/src/db.c @@ -1834,7 +1834,7 @@ db_build_query_count_items(struct query_params *qp) qp->results = 1; - query = sqlite3_mprintf("SELECT COUNT(*), SUM(song_length), COUNT(distinct songartistid), COUNT(distinct songalbumid) FROM files f %s;", qc->where); + query = sqlite3_mprintf("SELECT COUNT(*), SUM(song_length), COUNT(DISTINCT songartistid), COUNT(DISTINCT songalbumid) FROM files f %s;", qc->where); if (!query) DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index fc6bfb4c..92cb7e20 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -31,7 +31,6 @@ #endif #include -#include #include #include #include @@ -1895,7 +1894,7 @@ jsonapi_reply_library_artists(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -1957,7 +1956,7 @@ jsonapi_reply_library_artist(struct httpd_request *hreq) json_object *reply; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -1995,7 +1994,7 @@ jsonapi_reply_library_artist_albums(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2051,7 +2050,7 @@ jsonapi_reply_library_albums(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2113,7 +2112,7 @@ jsonapi_reply_library_album(struct httpd_request *hreq) json_object *reply; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2151,7 +2150,7 @@ jsonapi_reply_library_album_tracks(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2205,7 +2204,7 @@ jsonapi_reply_library_playlists(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2255,7 +2254,7 @@ jsonapi_reply_library_playlist(struct httpd_request *hreq) json_object *reply; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2293,7 +2292,7 @@ jsonapi_reply_library_playlist_tracks(struct httpd_request *hreq) int total; int ret = 0; - db_update = (time_t) db_admin_getint64(DB_ADMIN_START_TIME); + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) return HTTP_NOTMODIFIED; @@ -2343,6 +2342,7 @@ jsonapi_reply_library_playlist_tracks(struct httpd_request *hreq) static int jsonapi_reply_library_count(struct httpd_request *hreq) { + time_t db_update; const char *param_expression; char *expression; struct smartpl smartpl_expression; @@ -2352,6 +2352,10 @@ jsonapi_reply_library_count(struct httpd_request *hreq) int ret; + db_update = (time_t) db_admin_getint64(DB_ADMIN_DB_UPDATE); + if (db_update && httpd_request_not_modified_since(hreq->req, &db_update)) + return HTTP_NOTMODIFIED; + memset(&qp, 0, sizeof(struct query_params)); qp.type = Q_COUNT_ITEMS;