[db,jsonapi] add file_size to count query

This commit is contained in:
whatdoineed2do/Ray 2022-05-12 18:34:10 +01:00
parent 670ac7745d
commit 4418803aba
3 changed files with 5 additions and 1 deletions

View File

@ -2344,7 +2344,7 @@ db_build_query_count_items(struct query_params *qp, struct query_clause *qc)
qp->results = 1; 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), SUM(file_size) FROM files f %s;", qc->where);
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");
@ -2699,6 +2699,7 @@ db_query_fetch_count(struct filecount_info *fci, struct query_params *qp)
fci->length = sqlite3_column_int64(qp->stmt, 1); fci->length = sqlite3_column_int64(qp->stmt, 1);
fci->artist_count = sqlite3_column_int(qp->stmt, 2); fci->artist_count = sqlite3_column_int(qp->stmt, 2);
fci->album_count = sqlite3_column_int(qp->stmt, 3); fci->album_count = sqlite3_column_int(qp->stmt, 3);
fci->file_size = sqlite3_column_int64(qp->stmt, 4);
return 0; return 0;
} }

View File

@ -474,6 +474,7 @@ struct filecount_info {
uint64_t length; uint64_t length;
uint32_t artist_count; uint32_t artist_count;
uint32_t album_count; uint32_t album_count;
uint64_t file_size;
}; };
/* Directory ids must be in sync with the ids in Q_DIR* in db_init.c */ /* Directory ids must be in sync with the ids in Q_DIR* in db_init.c */

View File

@ -1205,6 +1205,7 @@ jsonapi_reply_library(struct httpd_request *hreq)
json_object_object_add(jreply, "db_playtime", json_object_new_int64((fci.length / 1000))); json_object_object_add(jreply, "db_playtime", json_object_new_int64((fci.length / 1000)));
json_object_object_add(jreply, "artists", json_object_new_int(fci.artist_count)); json_object_object_add(jreply, "artists", json_object_new_int(fci.artist_count));
json_object_object_add(jreply, "albums", json_object_new_int(fci.album_count)); json_object_object_add(jreply, "albums", json_object_new_int(fci.album_count));
json_object_object_add(jreply, "file_size", json_object_new_int64(fci.file_size));
} }
else else
{ {
@ -4163,6 +4164,7 @@ jsonapi_reply_library_count(struct httpd_request *hreq)
json_object_object_add(jreply, "artists", json_object_new_int(fci.artist_count)); json_object_object_add(jreply, "artists", json_object_new_int(fci.artist_count));
json_object_object_add(jreply, "albums", json_object_new_int(fci.album_count)); json_object_object_add(jreply, "albums", json_object_new_int(fci.album_count));
json_object_object_add(jreply, "db_playtime", json_object_new_int64((fci.length / 1000))); json_object_object_add(jreply, "db_playtime", json_object_new_int64((fci.length / 1000)));
json_object_object_add(jreply, "file_size", json_object_new_int64((fci.file_size)));
} }
else else
{ {