diff --git a/src/db.c b/src/db.c index 918e4c5c..28c96e3d 100644 --- a/src/db.c +++ b/src/db.c @@ -402,6 +402,9 @@ static const ssize_t dbgri_cols_map[] = dbgri_offsetof(media_kind), dbgri_offsetof(year), dbgri_offsetof(date_released), + dbgri_offsetof(time_added), + dbgri_offsetof(time_played), + dbgri_offsetof(seek), }; /* 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; 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); } @@ -1919,7 +1928,14 @@ db_build_query_group_artists(struct query_params *qp, struct query_clause *qc) char *query; 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); } diff --git a/src/db.h b/src/db.h index 4dec849c..ce2086a5 100644 --- a/src/db.h +++ b/src/db.h @@ -301,6 +301,9 @@ struct group_info { uint32_t media_kind; uint32_t year; uint32_t date_released; + uint32_t time_added; + uint32_t time_played; + uint32_t seek; }; #define gri_offsetof(field) offsetof(struct group_info, field) @@ -319,6 +322,9 @@ struct db_group_info { char *media_kind; char *year; char *date_released; + char *time_added; + char *time_played; + char *seek; }; #define dbgri_offsetof(field) offsetof(struct db_group_info, field)