Fixed: Speed up mass deletes from Movie Editor (#4463)
parent
913037c45e
commit
7adb358d1c
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download.History;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadHistoryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadHistoryRepositoryFixture : DbTest<DownloadHistoryRepository, DownloadHistory>
|
||||
{
|
||||
private Movie _movie1;
|
||||
private Movie _movie2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_movie1 = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Id = 7)
|
||||
.Build();
|
||||
|
||||
_movie2 = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Id = 8)
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_history_items_by_movieId()
|
||||
{
|
||||
var items = Builder<DownloadHistory>.CreateListOfSize(5)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.MovieId = _movie2.Id)
|
||||
.TheRest()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.MovieId = _movie1.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(items);
|
||||
|
||||
Subject.DeleteByMovieIds(new List<int> { _movie1.Id });
|
||||
|
||||
var removedItems = Subject.All().Where(h => h.MovieId == _movie1.Id);
|
||||
var nonRemovedItems = Subject.All().Where(h => h.MovieId == _movie2.Id);
|
||||
|
||||
removedItems.Should().HaveCount(0);
|
||||
nonRemovedItems.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Credits;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.MovieTests.CreditTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CreditRepositoryFixture : DbTest<CreditRepository, Credit>
|
||||
{
|
||||
private Movie _movie1;
|
||||
private Movie _movie2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_movie1 = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Id = 7)
|
||||
.Build();
|
||||
|
||||
_movie2 = Builder<Movie>.CreateNew()
|
||||
.With(s => s.Id = 8)
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_credits_by_movieId()
|
||||
{
|
||||
var credits = Builder<Credit>.CreateListOfSize(5)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.MovieId = _movie2.Id)
|
||||
.TheRest()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.MovieId = _movie1.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(credits);
|
||||
|
||||
Subject.DeleteForMovies(new List<int> { _movie1.Id });
|
||||
|
||||
var removedMovieCredits = Subject.FindByMovieId(_movie1.Id);
|
||||
var nonRemovedMovieCredits = Subject.FindByMovieId(_movie2.Id);
|
||||
|
||||
removedMovieCredits.Should().HaveCount(0);
|
||||
nonRemovedMovieCredits.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.Movies.Events
|
||||
{
|
||||
public class MoviesDeletedEvent : IEvent
|
||||
{
|
||||
public List<Movie> Movies { get; private set; }
|
||||
public bool DeleteFiles { get; private set; }
|
||||
public bool AddExclusion { get; private set; }
|
||||
|
||||
public MoviesDeletedEvent(List<Movie> movies, bool deleteFiles, bool addExclusion)
|
||||
{
|
||||
Movies = movies;
|
||||
DeleteFiles = deleteFiles;
|
||||
AddExclusion = addExclusion;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue