1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00

Fixed: Loading queue with pending releases for deleted series

This commit is contained in:
Bogdan 2024-10-31 17:16:33 +02:00 committed by Mark McDowall
parent 22005dc8c5
commit 38c0135d7c
3 changed files with 18 additions and 10 deletions

View File

@ -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)
{
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
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)
{
var wb = GetWhereBuilder(builder.DatabaseType, filter, false, builder.Sequence);
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)

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Download.Pending
{
@ -30,7 +31,11 @@ public List<PendingRelease> AllBySeriesId(int seriesId)
public List<PendingRelease> WithoutFallback()
{
return Query(p => p.Reason != PendingReleaseReason.Fallback);
var builder = new SqlBuilder(_database.DatabaseType)
.InnerJoin<PendingRelease, Series>((p, s) => p.SeriesId == s.Id)
.Where<PendingRelease>(p => p.Reason != PendingReleaseReason.Fallback);
return Query(builder);
}
}
}

View File

@ -274,10 +274,7 @@ private List<PendingRelease> IncludeRemoteEpisodes(List<PendingRelease> releases
{
foreach (var series in knownRemoteEpisodes.Values.Select(v => v.Series))
{
if (!seriesMap.ContainsKey(series.Id))
{
seriesMap[series.Id] = series;
}
seriesMap.TryAdd(series.Id, series);
}
}
@ -293,7 +290,7 @@ private List<PendingRelease> IncludeRemoteEpisodes(List<PendingRelease> releases
// Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up)
if (series == null)
{
return null;
continue;
}
// Languages will be empty if added before upgrading to v4, reparsing the languages if they're empty will set it to Unknown or better.