mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
New: Update DB to store all releases for an album (#517)
* New: Store all releases for an album and track artists * Add Overview, links and release date by release * Tidy up * Fix metadata refresh errors following musicbrainz edits
This commit is contained in:
@@ -29,7 +29,17 @@ namespace NzbDrone.Core.MediaFiles
|
||||
|
||||
public List<TrackFile> GetFilesByArtist(int artistId)
|
||||
{
|
||||
return Query.Where(c => c.ArtistId == artistId).ToList();
|
||||
string query = string.Format("SELECT TrackFiles.* " +
|
||||
"FROM Artists " +
|
||||
"JOIN Albums ON Albums.ArtistMetadataId = Artists.ArtistMetadataId " +
|
||||
"JOIN AlbumReleases ON AlbumReleases.AlbumId == Albums.Id " +
|
||||
"JOIN Tracks ON Tracks.AlbumReleaseId == AlbumReleases.Id " +
|
||||
"JOIN TrackFiles ON TrackFiles.Id == Tracks.TrackFileId " +
|
||||
"WHERE Artists.Id == {0} " +
|
||||
"AND AlbumReleases.Monitored = 1",
|
||||
artistId);
|
||||
|
||||
return Query.QueryText(query).ToList();
|
||||
}
|
||||
|
||||
public List<TrackFile> GetFilesByAlbum(int albumId)
|
||||
@@ -39,9 +49,20 @@ namespace NzbDrone.Core.MediaFiles
|
||||
|
||||
public List<TrackFile> GetFilesWithRelativePath(int artistId, string relativePath)
|
||||
{
|
||||
return Query.Where(c => c.ArtistId == artistId)
|
||||
.AndWhere(c => c.RelativePath == relativePath)
|
||||
.ToList();
|
||||
var mapper = DataMapper;
|
||||
mapper.AddParameter("artistId", artistId);
|
||||
mapper.AddParameter("relativePath", relativePath);
|
||||
string query = "SELECT TrackFiles.* " +
|
||||
"FROM Artists " +
|
||||
"JOIN Albums ON Albums.ArtistMetadataId = Artists.ArtistMetadataId " +
|
||||
"JOIN AlbumReleases ON AlbumReleases.AlbumId == Albums.Id " +
|
||||
"JOIN Tracks ON Tracks.AlbumReleaseId == AlbumReleases.Id " +
|
||||
"JOIN TrackFiles ON TrackFiles.Id == Tracks.TrackFileId " +
|
||||
"WHERE Artists.Id == @artistId " +
|
||||
"AND AlbumReleases.Monitored = 1 " +
|
||||
"AND TrackFiles.RelativePath == @relativePath";
|
||||
|
||||
return mapper.Query<TrackFile>(query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user