Write "friends" query

Will tell you which songs you listen to the most on the days you listen to some specified song
This commit is contained in:
mitteneer 2025-06-28 00:19:48 -04:00
parent 29041044e7
commit 5739f89e0d

View file

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