mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Removed Series.Episodes and Series.EpisodeFiles list.
This commit is contained in:
parent
aa836f6a88
commit
17d084cdf3
@ -22,7 +22,6 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 12)
|
||||
.With(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -44,26 +43,6 @@ namespace NzbDrone.Core.Test
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void series_with_no_episodes_should_skip_scan()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 12)
|
||||
.With(s => s.Episodes = new List<Episode>())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
|
||||
mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetSeries(series.SeriesId))
|
||||
.Returns(series);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), series.SeriesId);
|
||||
|
||||
//Assert
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void job_with_no_target_should_scan_all_series()
|
||||
@ -71,7 +50,6 @@ namespace NzbDrone.Core.Test
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.WhereAll().Have(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -100,7 +78,6 @@ namespace NzbDrone.Core.Test
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.WhereAll().Have(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -129,9 +106,7 @@ namespace NzbDrone.Core.Test
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.And(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.And(s => s.Episodes = new List<Episode>())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -144,10 +119,16 @@ namespace NzbDrone.Core.Test
|
||||
.Setup(s => s.Scan(series[0]))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0);
|
||||
|
||||
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
mocker.GetMock<MediaFileProvider>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,13 @@ namespace NzbDrone.Core.Test
|
||||
public void import_new_series_succesfull()
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereAll().Have(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.WhereAll().Have(s => s.LastInfoSync = null)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
|
||||
|
||||
var notification = new ProgressNotification("Test");
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -63,6 +64,12 @@ namespace NzbDrone.Core.Test
|
||||
.Setup(s => s.GetSeries(series[1].SeriesId)).Returns(series[1]);
|
||||
|
||||
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeBySeries(series[0].SeriesId)).Returns(episodes);
|
||||
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeBySeries(series[1].SeriesId)).Returns(episodes);
|
||||
|
||||
mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
||||
@ -81,12 +88,13 @@ namespace NzbDrone.Core.Test
|
||||
public void failed_import_should_not_be_stuck_in_loop()
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereAll().Have(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.WhereAll().Have(s => s.LastInfoSync = null)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
|
||||
|
||||
var notification = new ProgressNotification("Test");
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
@ -117,6 +125,9 @@ namespace NzbDrone.Core.Test
|
||||
mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(s => s.GetEpisodeBySeries(It.IsAny<long>())).Returns(episodes);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0);
|
||||
|
||||
|
@ -310,30 +310,16 @@ namespace NzbDrone.Core.Test
|
||||
mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.UpdateSeries(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
||||
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<long>()))
|
||||
.Returns(new List<Episode>{new Episode()});
|
||||
|
||||
mocker.Resolve<MediaFileProvider>().Scan(new Series());
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scan_media_job_should_not_scan_new_series()
|
||||
{
|
||||
var mocker = new AutoMoqer();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(c => c.Episodes = new List<Episode>())
|
||||
.AndTheNext(1).Has(c => c.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.Build();
|
||||
mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.GetAllSeries()).Returns(fakeSeries);
|
||||
|
||||
mocker.GetMock<MediaFileProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.Scan(fakeSeries.ToList()[1])).Returns(new List<EpisodeFile>()).Verifiable();
|
||||
|
||||
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("test"), 0);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_series_files()
|
||||
@ -390,7 +376,7 @@ namespace NzbDrone.Core.Test
|
||||
diskProvider.Setup(d => d.GetExtension(It.IsAny<string>())).Returns(".avi");
|
||||
|
||||
var episodeProvider = mocker.GetMock<EpisodeProvider>();
|
||||
episodeProvider.Setup(e => e.GetEpisodes(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> {fakeEpisode});
|
||||
episodeProvider.Setup(e => e.GetEpisodes(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
episodeProvider.Setup(e => e.GetEpisode(fakeSeries.SeriesId, 1, 5)).Returns(fakeEpisode);
|
||||
|
||||
var configProvider = mocker.GetMock<ConfigProvider>();
|
||||
@ -436,7 +422,7 @@ namespace NzbDrone.Core.Test
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.Quality = QualityTypes.SDTV)
|
||||
.With(e => e.Episodes = new List<Episode>{ fakeEpisode })
|
||||
.With(e => e.Episodes = new List<Episode> { fakeEpisode })
|
||||
.Build();
|
||||
|
||||
fakeEpisode.EpisodeFile = fakeEpisodeFile;
|
||||
@ -477,5 +463,26 @@ namespace NzbDrone.Core.Test
|
||||
mocker.VerifyAllMocks();
|
||||
Assert.AreEqual(1, result.Count);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Scan_series_should_skip_series_with_no_episodes()
|
||||
{
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodeBySeries(12))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 12).Build();
|
||||
|
||||
//Act
|
||||
mocker.Resolve<MediaFileProvider>().Scan(series);
|
||||
|
||||
//Assert
|
||||
mocker.VerifyAllMocks();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -203,7 +203,6 @@
|
||||
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
|
||||
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
|
||||
<Compile Include="Providers\SceneMappingProvider.cs" />
|
||||
<Compile Include="Providers\StatsProvider.cs" />
|
||||
<Compile Include="Repository\ExternalNotificationSetting.cs" />
|
||||
<Compile Include="Repository\JobSetting.cs" />
|
||||
<Compile Include="Repository\IndexerSetting.cs" />
|
||||
|
@ -47,7 +47,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||
seriesToScan = new List<Series>() { _seriesProvider.GetSeries(targetId) };
|
||||
}
|
||||
|
||||
foreach (var series in seriesToScan.Where(c => c.Episodes.Count != 0))
|
||||
foreach (var series in seriesToScan)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||
public class ImportNewSeriesJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly UpdateInfoJob _updateInfoJob;
|
||||
private readonly DiskScanJob _diskScanJob;
|
||||
@ -25,10 +26,11 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||
private List<int> _attemptedSeries;
|
||||
|
||||
[Inject]
|
||||
public ImportNewSeriesJob(SeriesProvider seriesProvider,
|
||||
public ImportNewSeriesJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
MediaFileProvider mediaFileProvider, UpdateInfoJob updateInfoJob, DiskScanJob diskScanJob)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_updateInfoJob = updateInfoJob;
|
||||
_diskScanJob = diskScanJob;
|
||||
@ -85,7 +87,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||
private void AutoIgnoreSeasons(Series updatedSeries)
|
||||
{
|
||||
var episodeFiles = _mediaFileProvider.GetSeriesFiles(updatedSeries.SeriesId);
|
||||
var episodes = updatedSeries.Episodes;
|
||||
var episodes = _episodeProvider.GetEpisodeBySeries(updatedSeries.SeriesId);
|
||||
if (episodeFiles.Count() != 0)
|
||||
{
|
||||
var seasons = episodes.Select(c => c.SeasonNumber).Distinct();
|
||||
@ -98,17 +100,6 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Logger.Debug("Looking for seasons to ignore");
|
||||
foreach (var season in updatedSeries.Seasons)
|
||||
{
|
||||
if (season.SeasonNumber != updatedSeries.Seasons.Max(s => s.SeasonNumber) && _mediaFileProvider.GetSeasonFiles(season.SeasonId).Count() == 0)
|
||||
{
|
||||
Logger.Info("Season {0} of {1} doesn't have any files on disk. season will not be monitored.", season.SeasonNumber, updatedSeries.Title);
|
||||
season.Monitored = false;
|
||||
_seasonProvider.SaveSeason(season);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,12 @@ namespace NzbDrone.Core.Providers
|
||||
/// <param name = "series">The series to be scanned</param>
|
||||
public virtual List<EpisodeFile> Scan(Series series)
|
||||
{
|
||||
if (_episodeProvider.GetEpisodeBySeries(series.SeriesId).Count == 0)
|
||||
{
|
||||
Logger.Debug("Series {0} has no episodes. skipping", series.Title);
|
||||
return new List<EpisodeFile>();
|
||||
}
|
||||
|
||||
var mediaFileList = GetMediaFileList(series.Path);
|
||||
var fileList = new List<EpisodeFile>();
|
||||
|
||||
|
@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class StatsProvider
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
|
||||
[Inject]
|
||||
public StatsProvider(SeriesProvider seriesProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
}
|
||||
|
||||
public virtual int SeriesCount()
|
||||
{
|
||||
return _seriesProvider.GetAllSeries().Count();
|
||||
}
|
||||
|
||||
public virtual int ActiveSeriesCount()
|
||||
{
|
||||
return _seriesProvider.GetAllSeries().Where(s => s.Status == "Continuing").Count();
|
||||
}
|
||||
|
||||
public virtual int EndedSeriesCount()
|
||||
{
|
||||
return _seriesProvider.GetAllSeries().Where(s => s.Status == "Ended").Count();
|
||||
}
|
||||
|
||||
public virtual int TotalEpisodesCount()
|
||||
{
|
||||
var count = 0;
|
||||
var series = _seriesProvider.GetAllSeries();
|
||||
foreach (var s in series)
|
||||
{
|
||||
count += s.Episodes.Count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual int TotalAiredEpisodesCount()
|
||||
{
|
||||
var count = 0;
|
||||
var series = _seriesProvider.GetAllSeries();
|
||||
foreach (var s in series)
|
||||
{
|
||||
count += s.Episodes.Where(e => e.AirDate.Date <= DateTime.Today).Count();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual int TotalUnairedEpisodesCount()
|
||||
{
|
||||
var count = 0;
|
||||
var series = _seriesProvider.GetAllSeries();
|
||||
foreach (var s in series)
|
||||
{
|
||||
count += s.Episodes.Where(e => e.AirDate.Date > DateTime.Today).Count();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual int TotalEpisodesOnDisk()
|
||||
{
|
||||
var count = 0;
|
||||
var series = _seriesProvider.GetAllSeries();
|
||||
foreach (var s in series)
|
||||
{
|
||||
count += s.Episodes.Where(e => e.EpisodeFileId != 0).Count();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -57,11 +57,5 @@ namespace NzbDrone.Core.Repository
|
||||
|
||||
[Ignore]
|
||||
public virtual QualityProfile QualityProfile { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public virtual IList<Episode> Episodes { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public virtual IList<EpisodeFile> EpisodeFiles { get; protected set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user