mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-27 05:19:18 -05:00
[db,jsonapi] add file_size to count query
This commit is contained in:
parent
670ac7745d
commit
4418803aba
3
src/db.c
3
src/db.c
@ -2344,7 +2344,7 @@ db_build_query_count_items(struct query_params *qp, struct query_clause *qc)
|
||||
|
||||
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)
|
||||
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->artist_count = sqlite3_column_int(qp->stmt, 2);
|
||||
fci->album_count = sqlite3_column_int(qp->stmt, 3);
|
||||
fci->file_size = sqlite3_column_int64(qp->stmt, 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1
src/db.h
1
src/db.h
@ -474,6 +474,7 @@ struct filecount_info {
|
||||
uint64_t length;
|
||||
uint32_t artist_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 */
|
||||
|
@ -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, "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, "file_size", json_object_new_int64(fci.file_size));
|
||||
}
|
||||
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, "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, "file_size", json_object_new_int64((fci.file_size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user