[db] Add fields time_added, time_played, seek to group object

This commit is contained in:
chme 2020-08-30 09:06:28 +02:00
parent 382467eb9c
commit a74a3e5add
2 changed files with 24 additions and 2 deletions

View File

@ -402,6 +402,9 @@ static const ssize_t dbgri_cols_map[] =
dbgri_offsetof(media_kind), dbgri_offsetof(media_kind),
dbgri_offsetof(year), dbgri_offsetof(year),
dbgri_offsetof(date_released), dbgri_offsetof(date_released),
dbgri_offsetof(time_added),
dbgri_offsetof(time_played),
dbgri_offsetof(seek),
}; };
/* This list must be kept in sync with /* This list must be kept in sync with
@ -1907,7 +1910,13 @@ db_build_query_group_albums(struct query_params *qp, struct query_clause *qc)
char *query; char *query;
count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.songalbumid) FROM files f %s;", qc->where); count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.songalbumid) FROM files f %s;", qc->where);
query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id) as track_count, 1 as album_count, f.album_artist, f.songartistid, SUM(f.song_length), MIN(f.data_kind), MIN(f.media_kind), MAX(f.year), MAX(f.date_released) FROM files f JOIN groups g ON f.songalbumid = g.persistentid %s GROUP BY f.songalbumid %s %s %s;", qc->where, qc->having, qc->order, qc->index); query = sqlite3_mprintf("SELECT " \
" g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id) as track_count, " \
" 1 as album_count, f.album_artist, f.songartistid, " \
" SUM(f.song_length), MIN(f.data_kind), MIN(f.media_kind), MAX(f.year), MAX(f.date_released), " \
" MAX(f.time_added), MAX(f.time_played), MAX(f.seek) " \
"FROM files f JOIN groups g ON f.songalbumid = g.persistentid %s " \
"GROUP BY f.songalbumid %s %s %s;", qc->where, qc->having, qc->order, qc->index);
return db_build_query_check(qp, count, query); return db_build_query_check(qp, count, query);
} }
@ -1919,7 +1928,14 @@ db_build_query_group_artists(struct query_params *qp, struct query_clause *qc)
char *query; char *query;
count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.songartistid) FROM files f %s;", qc->where); count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.songartistid) FROM files f %s;", qc->where);
query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id) as track_count, COUNT(DISTINCT f.songalbumid) as album_count, f.album_artist, f.songartistid, SUM(f.song_length), MIN(f.data_kind), MIN(f.media_kind), MAX(f.year), MAX(f.date_released) FROM files f JOIN groups g ON f.songartistid = g.persistentid %s GROUP BY f.songartistid %s %s %s;", qc->where, qc->having, qc->order, qc->index); query = sqlite3_mprintf("SELECT " \
" g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id) as track_count, " \
" COUNT(DISTINCT f.songalbumid) as album_count, f.album_artist, f.songartistid, " \
" SUM(f.song_length), MIN(f.data_kind), MIN(f.media_kind), MAX(f.year), MAX(f.date_released), " \
" MAX(f.time_added), MAX(f.time_played), MAX(f.seek) " \
"FROM files f JOIN groups g ON f.songartistid = g.persistentid %s " \
"GROUP BY f.songartistid %s %s %s;",
qc->where, qc->having, qc->order, qc->index);
return db_build_query_check(qp, count, query); return db_build_query_check(qp, count, query);
} }

View File

@ -301,6 +301,9 @@ struct group_info {
uint32_t media_kind; uint32_t media_kind;
uint32_t year; uint32_t year;
uint32_t date_released; uint32_t date_released;
uint32_t time_added;
uint32_t time_played;
uint32_t seek;
}; };
#define gri_offsetof(field) offsetof(struct group_info, field) #define gri_offsetof(field) offsetof(struct group_info, field)
@ -319,6 +322,9 @@ struct db_group_info {
char *media_kind; char *media_kind;
char *year; char *year;
char *date_released; char *date_released;
char *time_added;
char *time_played;
char *seek;
}; };
#define dbgri_offsetof(field) offsetof(struct db_group_info, field) #define dbgri_offsetof(field) offsetof(struct db_group_info, field)