1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-22 22:16:13 -04:00

New: Speed up mass deletes from Series Editor

* New: Speed up mass deletes from Series Editor

* fixup! Additional speed up using GetAllSeriesPaths vs GetAllSeries

* fixup! Tests
This commit is contained in:
Qstick
2022-12-10 14:19:10 -06:00
committed by GitHub
parent d08f33ae21
commit 356771d139
29 changed files with 290 additions and 86 deletions
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Blocklisting
{
@@ -14,6 +16,8 @@ namespace NzbDrone.Core.Test.Blocklisting
public class BlocklistRepositoryFixture : DbTest<BlocklistRepository, Blocklist>
{
private Blocklist _blocklist;
private Series _series1;
private Series _series2;
[SetUp]
public void Setup()
@@ -27,6 +31,14 @@ namespace NzbDrone.Core.Test.Blocklisting
SourceTitle = "series.title.s01e01",
Date = DateTime.UtcNow
};
_series1 = Builder<Series>.CreateNew()
.With(s => s.Id = 7)
.Build();
_series2 = Builder<Series>.CreateNew()
.With(s => s.Id = 8)
.Build();
}
[Test]
@@ -51,5 +63,30 @@ namespace NzbDrone.Core.Test.Blocklisting
Subject.BlocklistedByTitle(_blocklist.SeriesId, _blocklist.SourceTitle.ToUpperInvariant()).Should().HaveCount(1);
}
[Test]
public void should_delete_blocklists_by_seriesId()
{
var blocklistItems = Builder<Blocklist>.CreateListOfSize(5)
.TheFirst(1)
.With(c => c.SeriesId = _series2.Id)
.TheRest()
.With(c => c.SeriesId = _series1.Id)
.All()
.With(c => c.Quality = new QualityModel())
.With(c => c.Languages = new List<Language>())
.With(c => c.EpisodeIds = new List<int> { 1 })
.BuildListOfNew();
Db.InsertMany(blocklistItems);
Subject.DeleteForSeriesIds(new List<int> { _series1.Id });
var removedSeriesBlocklists = Subject.BlocklistedBySeries(_series1.Id);
var nonRemovedSeriesBlocklists = Subject.BlocklistedBySeries(_series2.Id);
removedSeriesBlocklists.Should().HaveCount(0);
nonRemovedSeriesBlocklists.Should().HaveCount(1);
}
}
}