mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 09:33:52 -07:00
Fixed: Display last/next monitored albums for artists
This commit is contained in:
parent
eb04673040
commit
a52c6f6f41
8 changed files with 17 additions and 18 deletions
|
@ -10,6 +10,7 @@ export interface Statistics {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Album extends ModelBase {
|
interface Album extends ModelBase {
|
||||||
|
artistId: number;
|
||||||
artist: Artist;
|
artist: Artist;
|
||||||
foreignAlbumId: string;
|
foreignAlbumId: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
|
@ -4,10 +4,11 @@ import Link from 'Components/Link/Link';
|
||||||
|
|
||||||
function AlbumTitleLink({ foreignAlbumId, title, disambiguation }) {
|
function AlbumTitleLink({ foreignAlbumId, title, disambiguation }) {
|
||||||
const link = `/album/${foreignAlbumId}`;
|
const link = `/album/${foreignAlbumId}`;
|
||||||
|
const albumTitle = `${title}${disambiguation ? ` (${disambiguation})` : ''}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link to={link}>
|
<Link to={link} title={albumTitle}>
|
||||||
{title}{disambiguation ? ` (${disambiguation})` : ''}
|
{albumTitle}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ export interface Ratings {
|
||||||
|
|
||||||
interface Artist extends ModelBase {
|
interface Artist extends ModelBase {
|
||||||
added: string;
|
added: string;
|
||||||
artistMetadataId: string;
|
|
||||||
foreignArtistId: string;
|
foreignArtistId: string;
|
||||||
cleanName: string;
|
cleanName: string;
|
||||||
ended: boolean;
|
ended: boolean;
|
||||||
|
|
|
@ -11,7 +11,7 @@ function createArtistAlbumsSelector(artistId: number) {
|
||||||
const { isFetching, isPopulated, error, items } = albums;
|
const { isFetching, isPopulated, error, items } = albums;
|
||||||
|
|
||||||
const filteredAlbums = items.filter(
|
const filteredAlbums = items.filter(
|
||||||
(album) => album.artist.artistMetadataId === artist.artistMetadataId
|
(album) => album.artistId === artist.id
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Lidarr.Api.V1.Albums;
|
using Lidarr.Api.V1.Albums;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
|
@ -32,7 +32,10 @@ namespace Lidarr.Api.V1.Artist
|
||||||
public string Disambiguation { get; set; }
|
public string Disambiguation { get; set; }
|
||||||
public List<Links> Links { get; set; }
|
public List<Links> Links { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
public AlbumResource NextAlbum { get; set; }
|
public AlbumResource NextAlbum { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
public AlbumResource LastAlbum { get; set; }
|
public AlbumResource LastAlbum { get; set; }
|
||||||
|
|
||||||
public List<MediaCover> Images { get; set; }
|
public List<MediaCover> Images { get; set; }
|
||||||
|
@ -74,7 +77,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
return new ArtistResource
|
return new ArtistResource
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ArtistMetadataId = model.ArtistMetadataId,
|
|
||||||
|
|
||||||
ArtistName = model.Name,
|
ArtistName = model.Name,
|
||||||
|
|
||||||
|
|
|
@ -8670,10 +8670,6 @@
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int32"
|
"format": "int32"
|
||||||
},
|
},
|
||||||
"artistMetadataId": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "int32"
|
|
||||||
},
|
|
||||||
"status": {
|
"status": {
|
||||||
"$ref": "#/components/schemas/ArtistStatusType"
|
"$ref": "#/components/schemas/ArtistStatusType"
|
||||||
},
|
},
|
||||||
|
|
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests
|
||||||
GivenMultipleAlbums();
|
GivenMultipleAlbums();
|
||||||
|
|
||||||
var result = _albumRepo.GetNextAlbums(new[] { _artist.ArtistMetadataId });
|
var result = _albumRepo.GetNextAlbums(new[] { _artist.ArtistMetadataId });
|
||||||
result.Should().BeEquivalentTo(_albums.Take(1), AlbumComparerOptions);
|
result.Should().BeEquivalentTo(_albums.Skip(1).Take(1), AlbumComparerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests
|
||||||
GivenMultipleAlbums();
|
GivenMultipleAlbums();
|
||||||
|
|
||||||
var result = _albumRepo.GetLastAlbums(new[] { _artist.ArtistMetadataId });
|
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>()
|
private EquivalencyAssertionOptions<Album> AlbumComparerOptions(EquivalencyAssertionOptions<Album> opts) => opts.ComparingByMembers<Album>()
|
||||||
|
|
|
@ -46,13 +46,13 @@ namespace NzbDrone.Core.Music
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
var inner = Builder()
|
var inner = Builder()
|
||||||
.Select("MIN(\"Albums\".\"Id\") as id, MAX(\"Albums\".\"ReleaseDate\") as date")
|
.Select("\"Albums\".\"ArtistMetadataId\" AS artist_metadata_id, MAX(\"Albums\".\"ReleaseDate\") AS date")
|
||||||
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.ReleaseDate < now)
|
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.Monitored == true && x.ReleaseDate < now)
|
||||||
.GroupBy<Album>(x => x.ArtistMetadataId)
|
.GroupBy<Album>(x => x.ArtistMetadataId)
|
||||||
.AddSelectTemplate(typeof(Album));
|
.AddSelectTemplate(typeof(Album));
|
||||||
|
|
||||||
var outer = Builder()
|
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);
|
.AddParameters(inner.Parameters);
|
||||||
|
|
||||||
return Query(outer);
|
return Query(outer);
|
||||||
|
@ -63,13 +63,13 @@ namespace NzbDrone.Core.Music
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
var inner = Builder()
|
var inner = Builder()
|
||||||
.Select("MIN(\"Albums\".\"Id\") as id, MIN(\"Albums\".\"ReleaseDate\") as date")
|
.Select("\"Albums\".\"ArtistMetadataId\" AS artist_metadata_id, MIN(\"Albums\".\"ReleaseDate\") AS date")
|
||||||
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.ReleaseDate > now)
|
.Where<Album>(x => artistMetadataIds.Contains(x.ArtistMetadataId) && x.Monitored == true && x.ReleaseDate > now)
|
||||||
.GroupBy<Album>(x => x.ArtistMetadataId)
|
.GroupBy<Album>(x => x.ArtistMetadataId)
|
||||||
.AddSelectTemplate(typeof(Album));
|
.AddSelectTemplate(typeof(Album));
|
||||||
|
|
||||||
var outer = Builder()
|
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);
|
.AddParameters(inner.Parameters);
|
||||||
|
|
||||||
return Query(outer);
|
return Query(outer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue