Merge pull request #1472 from whatdoineed2do/db-count-query-incl-filesize

[db,jsonapi,smartpl] add `file_size` to count query and expose on smartpl
This commit is contained in:
Christian Meffert 2022-05-15 06:53:40 +02:00 committed by GitHub
commit 96b678925a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 1 deletions

View File

@ -49,6 +49,7 @@ Where valid field-names (with their types) are:
* `time_played` (date)
* `time_skipped` (date)
* `random` (special)
* `file_size` (integer)
Valid operators include:

View File

@ -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;
}

View File

@ -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 */

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, "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
{

View File

@ -86,6 +86,7 @@ bits_per_sample { yylval->str = strdup(yytext); return SMARTPL_T_INTTAG; }
samplerate { yylval->str = strdup(yytext); return SMARTPL_T_INTTAG; }
song_length { yylval->str = strdup(yytext); return SMARTPL_T_INTTAG; }
usermark { yylval->str = strdup(yytext); return SMARTPL_T_INTTAG; }
file_size { yylval->str = strdup(yytext); return SMARTPL_T_INTTAG; }
time_added { yylval->str = strdup(yytext); return SMARTPL_T_DATETAG; }
time_modified { yylval->str = strdup(yytext); return SMARTPL_T_DATETAG; }