From 0e90f51cfafdd6f78de76e808ac167a2e2dcd6e6 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Mon, 19 Oct 2026 08:55:06 +0000 Subject: [PATCH] library: name album and track credits in the shared album rows Use 'album' and 'track' instead of a 1/0 flag so the credit kind is readable without a comment. This column is a constant in the SQL, not a stored value, and only the per-artist credit query compares it, so the text costs nothing meaningful. --- .../main/kotlin/com/subtracks/data/db/LibraryDao.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/data/db/LibraryDao.kt b/app/src/main/kotlin/com/subtracks/data/db/LibraryDao.kt index cedf4ede..d43c11ac 100644 --- a/app/src/main/kotlin/com/subtracks/data/db/LibraryDao.kt +++ b/app/src/main/kotlin/com/subtracks/data/db/LibraryDao.kt @@ -93,21 +93,20 @@ internal const val CREDITED_SONG_ROWS = "WHERE album_artists.sourceId = :sourceId" // May repeat an (artistId, albumId) pair when several credit paths reach it; consumers dedupe. -// albumCredit is 1 for album-level credits and 0 for track-level ones. internal const val CREDITED_ALBUM_ROWS = - "SELECT albums.artistId AS artistId, albums.id AS albumId, 1 AS albumCredit " + + "SELECT albums.artistId AS artistId, albums.id AS albumId, 'album' AS creditType " + "FROM albums WHERE albums.sourceId = :sourceId AND albums.artistId IS NOT NULL " + "UNION ALL " + - "SELECT album_artists.artistId, albums.id, 1 " + + "SELECT album_artists.artistId, albums.id, 'album' " + "FROM album_artists JOIN albums " + "ON albums.sourceId = album_artists.sourceId AND albums.id = album_artists.albumId " + "WHERE album_artists.sourceId = :sourceId " + "UNION ALL " + - "SELECT songs.artistId, songs.albumId, 0 " + + "SELECT songs.artistId, songs.albumId, 'track' " + "FROM songs JOIN albums ON albums.sourceId = songs.sourceId AND albums.id = songs.albumId " + "WHERE songs.sourceId = :sourceId AND songs.artistId IS NOT NULL " + "UNION ALL " + - "SELECT song_artists.artistId, songs.albumId, 0 " + + "SELECT song_artists.artistId, songs.albumId, 'track' " + "FROM song_artists JOIN songs " + "ON songs.sourceId = song_artists.sourceId AND songs.id = song_artists.songId " + "JOIN albums ON albums.sourceId = songs.sourceId AND albums.id = songs.albumId " + @@ -120,7 +119,7 @@ internal const val ALBUMS_FOR_ARTIST = internal const val ALBUM_CREDIT_ALBUM_IDS = "SELECT DISTINCT albumId FROM ($CREDITED_ALBUM_ROWS) " + - "WHERE artistId = :artistId AND albumCredit = 1" + "WHERE artistId = :artistId AND creditType = 'album'" // Download visibility follows the credit path: an album credit includes the album when any song is // downloaded, while a track credit includes it only when the credited track is downloaded.