From 5739f89e0d5241d70ea98c103e1ecf950ac5cf32 Mon Sep 17 00:00:00 2001 From: mitteneer Date: Sat, 28 Jun 2025 00:19:48 -0400 Subject: [PATCH] Write "friends" query Will tell you which songs you listen to the most on the days you listen to some specified song --- src/queries.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/queries.zig b/src/queries.zig index e298ea3..a665a58 100644 --- a/src/queries.zig +++ b/src/queries.zig @@ -457,3 +457,18 @@ pub fn loadQuery(entity: EntityType, query_type: QueryTypeEnum) GeneratedQuery { }, }; } + +// I'm pretty sure this query will tell you the number of days a song was played on the same day as a specified song +// The output looked right at least. Can easily be changed into the number of times a song was played on the same day +// as a specified song by removing DISTINCT from the first subquery (which would increase the count if a song was +// played more than once in a day) + +//SELECT COUNT(albumsong), name +//FROM ( +// SELECT DISTINCT scrobbles.albumsong, songs.name, TO_CHAR(scrobbles.datetime, 'YYYY-MM-DD') +// FROM scrobbles +// INNER JOIN albumsongs ON albumsongs.id = scrobbles.albumsong +// INNER JOIN songs ON songs.id = albumsongs.song_id +// WHERE TO_CHAR(datetime,'YYYY-MM-DD') IN ( +// SELECT DISTINCT TO_CHAR(datetime,'YYYY-MM-DD') FROM scrobbles WHERE albumsong = $1 +//)) GROUP BY albumsong, name ORDER BY COUNT(albumsong) DESC, name ASC;