Fixed: Display last/next monitored albums for artists

pull/4906/head
Bogdan 4 months ago
parent eb04673040
commit a52c6f6f41

@ -10,6 +10,7 @@ export interface Statistics {
}
interface Album extends ModelBase {
artistId: number;
artist: Artist;
foreignAlbumId: string;
title: string;

@ -4,10 +4,11 @@ import Link from 'Components/Link/Link';
function AlbumTitleLink({ foreignAlbumId, title, disambiguation }) {
const link = `/album/${foreignAlbumId}`;
const albumTitle = `${title}${disambiguation ? ` (${disambiguation})` : ''}`;
return (
<Link to={link}>
{title}{disambiguation ? ` (${disambiguation})` : ''}
<Link to={link} title={albumTitle}>
{albumTitle}
</Link>
);
}

@ -23,7 +23,6 @@ export interface Ratings {
interface Artist extends ModelBase {
added: string;
artistMetadataId: string;
foreignArtistId: string;
cleanName: string;
ended: boolean;

@ -11,7 +11,7 @@ function createArtistAlbumsSelector(artistId: number) {
const { isFetching, isPopulated, error, items } = albums;
const filteredAlbums = items.filter(
(album) => album.artist.artistMetadataId === artist.artistMetadataId
(album) => album.artistId === artist.id
);
return {

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Lidarr.Api.V1.Albums;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
@ -32,7 +32,10 @@ namespace Lidarr.Api.V1.Artist
public string Disambiguation { get; set; }
public List<Links> Links { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public AlbumResource NextAlbum { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public AlbumResource LastAlbum { get; set; }
public List<MediaCover> Images { get; set; }
@ -74,7 +77,6 @@ namespace Lidarr.Api.V1.Artist
return new ArtistResource
{
Id = model.Id,
ArtistMetadataId = model.ArtistMetadataId,
ArtistName = model.Name,

@ -8670,10 +8670,6 @@
"type": "integer",
"format": "int32"
},
"artistMetadataId": {
"type": "integer",
"format": "int32"
},
"status": {
"$ref": "#/components/schemas/ArtistStatusType"
},

@ -193,7 +193,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests
GivenMultipleAlbums();
var result = _albumRepo.GetNextAlbums(new[] { _artist.ArtistMetadataId });
result.Should().BeEquivalentTo(_albums.Take(1), AlbumComparerOptions);
result.Should().BeEquivalentTo(_albums.Skip(1).Take(1), AlbumComparerOptions);
}
[Test]
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests
GivenMultipleAlbums();
var result = _albumRepo.GetLastAlbums(new[] { _artist.ArtistMetadataId });
result.Should().BeEquivalentTo(_albums.Skip(2).Take(1), AlbumComparerOptions);
result.Should().BeEquivalentTo(_albums.Skip(3).Take(1), AlbumComparerOptions);
}
private EquivalencyAssertionOptions<Album> AlbumComparerOptions(EquivalencyAssertionOptions<Album> opts) => opts.ComparingByMembers<Album>()

@ -46,13 +46,13 @@ namespace NzbDrone.Core.Music
var now = DateTime.UtcNow;
var inner = Builder()
.Select("MIN(\"Albums\".\"Id\") as id, MAX(\"Albums\".\"ReleaseDate\") as date")
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.ReleaseDate < now)
.Select("\"Albums\".\"ArtistMetadataId\" AS artist_metadata_id, MAX(\"Albums\".\"ReleaseDate\") AS date")
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.Monitored == true && x.ReleaseDate < now)
.GroupBy<Album>(x => x.ArtistMetadataId)
.AddSelectTemplate(typeof(Album));
var outer = Builder()
.Join($"({inner.RawSql}) ids on ids.id = \"Albums\".\"Id\" and ids.date = \"Albums\".\"ReleaseDate\"")
.Join($"({inner.RawSql}) ids ON ids.artist_metadata_id = \"Albums\".\"ArtistMetadataId\" AND ids.date = \"Albums\".\"ReleaseDate\"")
.AddParameters(inner.Parameters);
return Query(outer);
@ -63,13 +63,13 @@ namespace NzbDrone.Core.Music
var now = DateTime.UtcNow;
var inner = Builder()
.Select("MIN(\"Albums\".\"Id\") as id, MIN(\"Albums\".\"ReleaseDate\") as date")
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.ReleaseDate > now)
.Select("\"Albums\".\"ArtistMetadataId\" AS artist_metadata_id, MIN(\"Albums\".\"ReleaseDate\") AS date")
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.Monitored == true && x.ReleaseDate > now)
.GroupBy<Album>(x => x.ArtistMetadataId)
.AddSelectTemplate(typeof(Album));
var outer = Builder()
.Join($"({inner.RawSql}) ids on ids.id = \"Albums\".\"Id\" and ids.date = \"Albums\".\"ReleaseDate\"")
.Join($"({inner.RawSql}) ids ON ids.artist_metadata_id = \"Albums\".\"ArtistMetadataId\" AND ids.date = \"Albums\".\"ReleaseDate\"")
.AddParameters(inner.Parameters);
return Query(outer);

Loading…
Cancel
Save