mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-02 21:15:05 +00:00
Fixed: Loading queue with pending releases for deleted artists
(cherry picked from commit 38c0135d7cd05b22bede934f8571c439dcf70a88) Closes #5214
This commit is contained in:
parent
29d17c6347
commit
3f81e0254f
3 changed files with 18 additions and 10 deletions
|
@ -64,19 +64,25 @@ public static SqlBuilder OrWhere<TModel>(this SqlBuilder builder, Expression<Fun
|
||||||
public static SqlBuilder Join<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
|
public static SqlBuilder Join<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
|
||||||
{
|
{
|
||||||
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
|
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
|
||||||
|
|
||||||
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
|
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
|
||||||
|
|
||||||
return builder.Join($"\"{rightTable}\" ON {wb.ToString()}");
|
return builder.Join($"\"{rightTable}\" ON {wb}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SqlBuilder LeftJoin<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
|
public static SqlBuilder LeftJoin<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
|
||||||
{
|
{
|
||||||
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
|
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
|
||||||
|
|
||||||
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
|
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
|
||||||
|
|
||||||
return builder.LeftJoin($"\"{rightTable}\" ON {wb.ToString()}");
|
return builder.LeftJoin($"\"{rightTable}\" ON {wb}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SqlBuilder InnerJoin<TLeft, TRight>(this SqlBuilder builder, Expression<Func<TLeft, TRight, bool>> filter)
|
||||||
|
{
|
||||||
|
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
|
||||||
|
var rightTable = TableMapping.Mapper.TableNameMapping(typeof(TRight));
|
||||||
|
|
||||||
|
return builder.InnerJoin($"\"{rightTable}\" ON {wb}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SqlBuilder GroupBy<TModel>(this SqlBuilder builder, Expression<Func<TModel, object>> property)
|
public static SqlBuilder GroupBy<TModel>(this SqlBuilder builder, Expression<Func<TModel, object>> property)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Pending
|
namespace NzbDrone.Core.Download.Pending
|
||||||
{
|
{
|
||||||
|
@ -30,7 +31,11 @@ public List<PendingRelease> AllByArtistId(int artistId)
|
||||||
|
|
||||||
public List<PendingRelease> WithoutFallback()
|
public List<PendingRelease> WithoutFallback()
|
||||||
{
|
{
|
||||||
return Query(p => p.Reason != PendingReleaseReason.Fallback);
|
var builder = new SqlBuilder(_database.DatabaseType)
|
||||||
|
.InnerJoin<PendingRelease, Artist>((p, s) => p.ArtistId == s.Id)
|
||||||
|
.Where<PendingRelease>(p => p.Reason != PendingReleaseReason.Fallback);
|
||||||
|
|
||||||
|
return Query(builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,10 +273,7 @@ private List<PendingRelease> IncludeRemoteAlbums(List<PendingRelease> releases,
|
||||||
{
|
{
|
||||||
foreach (var artist in knownRemoteAlbums.Values.Select(v => v.Artist))
|
foreach (var artist in knownRemoteAlbums.Values.Select(v => v.Artist))
|
||||||
{
|
{
|
||||||
if (!artistMap.ContainsKey(artist.Id))
|
artistMap.TryAdd(artist.Id, artist);
|
||||||
{
|
|
||||||
artistMap[artist.Id] = artist;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +289,7 @@ private List<PendingRelease> IncludeRemoteAlbums(List<PendingRelease> releases,
|
||||||
// Just in case the artist was removed, but wasn't cleaned up yet (housekeeper will clean it up)
|
// Just in case the artist was removed, but wasn't cleaned up yet (housekeeper will clean it up)
|
||||||
if (artist == null)
|
if (artist == null)
|
||||||
{
|
{
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
release.RemoteAlbum = new RemoteAlbum
|
release.RemoteAlbum = new RemoteAlbum
|
||||||
|
|
Loading…
Reference in a new issue