From c9488351e4339fd40a309386d58c6ff219177a77 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Feb 2018 00:40:32 -0500 Subject: [PATCH] Misc Cleanup --- .../Artist/AlternateTitleResource.cs | 2 +- .../DailySeriesDataProxyFixture.cs | 27 ------- .../FetchAndParseRssServiceFixture.cs | 78 ------------------- .../FetchAndParseRssServiceFixture.cs | 65 ---------------- .../NzbDrone.Core.Test.csproj | 1 - .../DailySeries/DailySeries.cs | 7 -- .../DailySeries/DailySeriesDataProxy.cs | 46 ----------- .../DailySeries/DailySeriesService.cs | 30 ------- .../Search/DailyAudioMatchSpecification.cs | 27 ------- src/NzbDrone.Core/Music/TrackRepository.cs | 18 ++--- src/NzbDrone.Core/NzbDrone.Core.csproj | 4 - .../ApiTests/TrackFixture.cs | 13 ++-- 12 files changed, 15 insertions(+), 303 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs delete mode 100644 src/NzbDrone.Core.Test/IndexerSearchTests/FetchAndParseRssServiceFixture.cs delete mode 100644 src/NzbDrone.Core.Test/IndexerTests/FetchAndParseRssServiceFixture.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs delete mode 100644 src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs delete mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs diff --git a/src/Lidarr.Api.V1/Artist/AlternateTitleResource.cs b/src/Lidarr.Api.V1/Artist/AlternateTitleResource.cs index 6da1c997f..0cecb77fb 100644 --- a/src/Lidarr.Api.V1/Artist/AlternateTitleResource.cs +++ b/src/Lidarr.Api.V1/Artist/AlternateTitleResource.cs @@ -1,4 +1,4 @@ -namespace Lidarr.Api.V1.Series +namespace Lidarr.Api.V1.Artist { public class AlternateTitleResource { diff --git a/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs deleted file mode 100644 index b429e24b2..000000000 --- a/src/NzbDrone.Core.Test/DataAugmentation/DailySeries/DailySeriesDataProxyFixture.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.DataAugmentation.DailySeries; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common.Categories; - -namespace NzbDrone.Core.Test.DataAugmentation.DailySeries -{ - [TestFixture] - [IntegrationTest] - public class DailySeriesDataProxyFixture : CoreTest - { - [SetUp] - public void Setup() - { - UseRealHttp(); - } - - [Test] - public void should_get_list_of_daily_series() - { - var list = Subject.GetDailySeriesIds(); - list.Should().NotBeEmpty(); - list.Should().OnlyHaveUniqueItems(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/FetchAndParseRssServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/FetchAndParseRssServiceFixture.cs deleted file mode 100644 index 7b96b7690..000000000 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/FetchAndParseRssServiceFixture.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections.Generic; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.IndexerSearch; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Indexers; -using NzbDrone.Core.Indexers.Newznab; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.IndexerSearchTests -{ - public class NzbSearchServiceFixture : CoreTest - { - private List _indexers; - - private Series _searchTargetSeries; - - [SetUp] - public void Setup() - { - - _searchTargetSeries = Builder.CreateNew().BuildNew(); - - _indexers = new List(); - - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - - Mocker.SetConstant>(_indexers); - - Mocker.GetMock().Setup(c => c.GetSeries(It.IsAny())) - .Returns(_searchTargetSeries); - - } - - [Test] - public void should_call_fetch_on_all_indexers_at_the_same_time() - { - - var counter = new ConcurrencyCounter(_indexers.Count); - - Mocker.GetMock().Setup(c => c.Fetch(It.IsAny(), It.IsAny())) - .Returns(new List()) - .Callback((() => counter.SimulateWork(500))); - - Mocker.GetMock().Setup(c => c.GetAvailableIndexers()).Returns(_indexers); - - Mocker.GetMock() - .Setup(c => c.GetSearchDecision(It.IsAny>(), It.IsAny())) - .Returns(new List()); - - Subject.SearchSingle(0, 0, 0); - - counter.WaitForAllItems(); - - counter.MaxThreads.Should().Be(_indexers.Count); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerTests/FetchAndParseRssServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FetchAndParseRssServiceFixture.cs deleted file mode 100644 index 6dd685d9e..000000000 --- a/src/NzbDrone.Core.Test/IndexerTests/FetchAndParseRssServiceFixture.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Indexers; -using NzbDrone.Core.Indexers.Newznab; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.IndexerTests -{ - public class FetchAndParseRssServiceFixture : CoreTest - { - private List _indexers; - - [SetUp] - public void Setup() - { - _indexers = new List(); - - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - _indexers.Add(new Newznab()); - - Mocker.SetConstant>(_indexers); - - } - - [Test] - [Explicit] - public void should_call_fetch_on_all_indexers_at_the_same_time() - { - - var counter = new ConcurrencyCounter(_indexers.Count); - - Mocker.GetMock().Setup(c => c.FetchRss(It.IsAny())) - .Returns(new List()) - .Callback((() => counter.SimulateWork(500))); - - Mocker.GetMock().Setup(c => c.GetAvailableIndexers()).Returns(_indexers); - - Subject.Fetch(); - - counter.WaitForAllItems(); - - counter.MaxThreads.Should().Be(_indexers.Count); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 98d37f65f..ca00b2df7 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -103,7 +103,6 @@ - diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs deleted file mode 100644 index 829ce6a24..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeries.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public class DailySeries - { - public int TvdbId { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs deleted file mode 100644 index 53b4dc9d9..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; -using NzbDrone.Common.Cloud; -using NzbDrone.Common.Http; - -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public interface IDailySeriesDataProxy - { - IEnumerable GetDailySeriesIds(); - } - - public class DailySeriesDataProxy : IDailySeriesDataProxy - { - private readonly IHttpClient _httpClient; - private readonly IHttpRequestBuilderFactory _requestBuilder; - private readonly Logger _logger; - - public DailySeriesDataProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, Logger logger) - { - _httpClient = httpClient; - _requestBuilder = requestBuilder.Services; - _logger = logger; - } - - public IEnumerable GetDailySeriesIds() - { - try - { - var dailySeriesRequest = _requestBuilder.Create() - .Resource("/dailyseries") - .Build(); - - var response = _httpClient.Get>(dailySeriesRequest); - return response.Resource.Select(c => c.TvdbId); - } - catch (Exception ex) - { - _logger.Warn(ex, "Failed to get Daily Series"); - return new List(); - } - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs b/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs deleted file mode 100644 index 6eb5f874a..000000000 --- a/src/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Common.Cache; - -namespace NzbDrone.Core.DataAugmentation.DailySeries -{ - public interface IDailySeriesService - { - bool IsDailySeries(int tvdbid); - } - - public class DailySeriesService : IDailySeriesService - { - private readonly IDailySeriesDataProxy _proxy; - private readonly ICached> _cache; - - public DailySeriesService(IDailySeriesDataProxy proxy, ICacheManager cacheManager) - { - _proxy = proxy; - _cache = cacheManager.GetCache>(GetType()); - } - - public bool IsDailySeries(int tvdbid) - { - var dailySeries = _cache.Get("all", () => _proxy.GetDailySeriesIds().ToList(), TimeSpan.FromHours(1)); - return dailySeries.Any(i => i == tvdbid); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs deleted file mode 100644 index 76fc116b9..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class DailyAudioMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public DailyAudioMatchSpecification(Logger logger) - { - _logger = logger; - } - - public SpecificationPriority Priority => SpecificationPriority.Database; - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) - { - throw new NotImplementedException(); - - // TODO Rework for Daily Audio/Podcasts - } - } -} diff --git a/src/NzbDrone.Core/Music/TrackRepository.cs b/src/NzbDrone.Core/Music/TrackRepository.cs index 7872708fc..1bb8531f9 100644 --- a/src/NzbDrone.Core/Music/TrackRepository.cs +++ b/src/NzbDrone.Core/Music/TrackRepository.cs @@ -79,14 +79,12 @@ namespace NzbDrone.Core.Music public PagingSpec TracksWhereCutoffUnmet(PagingSpec pagingSpec, List qualitiesBelowCutoff) { - pagingSpec.TotalRecords = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).GetRowCount(); - pagingSpec.Records = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).ToList(); + pagingSpec.TotalRecords = TracksWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).GetRowCount(); + pagingSpec.Records = TracksWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).ToList(); return pagingSpec; } - - public void SetMonitoredFlat(Track track, bool monitored) { track.Monitored = monitored; @@ -109,22 +107,22 @@ namespace NzbDrone.Core.Music mapper.ExecuteNonQuery(sql); } - public void SetFileId(int episodeId, int fileId) + public void SetFileId(int trackId, int fileId) { - SetFields(new Track { Id = episodeId, TrackFileId = fileId }, track => track.TrackFileId); + SetFields(new Track { Id = trackId, TrackFileId = fileId }, track => track.TrackFileId); } public PagingSpec TracksWithoutFiles(PagingSpec pagingSpec) { var currentTime = DateTime.UtcNow; - pagingSpec.TotalRecords = GetMissingEpisodesQuery(pagingSpec, currentTime).GetRowCount(); - pagingSpec.Records = GetMissingEpisodesQuery(pagingSpec, currentTime).ToList(); + pagingSpec.TotalRecords = GetMissingTracksQuery(pagingSpec, currentTime).GetRowCount(); + pagingSpec.Records = GetMissingTracksQuery(pagingSpec, currentTime).ToList(); return pagingSpec; } - private SortBuilder GetMissingEpisodesQuery(PagingSpec pagingSpec, DateTime currentTime) + private SortBuilder GetMissingTracksQuery(PagingSpec pagingSpec, DateTime currentTime) { return Query.Join(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id) .Where(pagingSpec.FilterExpression) @@ -136,7 +134,7 @@ namespace NzbDrone.Core.Music } - private SortBuilder EpisodesWhereCutoffUnmetQuery(PagingSpec pagingSpec, List qualitiesBelowCutoff) + private SortBuilder TracksWhereCutoffUnmetQuery(PagingSpec pagingSpec, List qualitiesBelowCutoff) { return Query.Join(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id) .Join(JoinType.Left, e => e.TrackFile, (e, s) => e.TrackFileId == s.Id) diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index b3a527c2f..e7460cf46 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -142,9 +142,6 @@ - - - @@ -231,7 +228,6 @@ - diff --git a/src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs index 3b3e094ab..16283235b 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs @@ -1,7 +1,6 @@ using System.Threading; using FluentAssertions; using NUnit.Framework; -using Lidarr.Api.V1.Series; using Lidarr.Api.V1.Artist; using System.Linq; using NzbDrone.Test.Common; @@ -11,12 +10,12 @@ namespace NzbDrone.Integration.Test.ApiTests [TestFixture] public class TrackFixture : IntegrationTest { - private ArtistResource artist; + private ArtistResource _artist; [SetUp] public void Setup() { - artist = GivenArtistWithTracks(); + _artist = GivenArtistWithTracks(); } private ArtistResource GivenArtistWithTracks() @@ -36,13 +35,13 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_be_able_to_get_all_tracks_in_artist() { - Tracks.GetTracksInArtist(artist.Id).Count.Should().BeGreaterThan(0); + Tracks.GetTracksInArtist(_artist.Id).Count.Should().BeGreaterThan(0); } [Test] public void should_be_able_to_get_a_single_track() { - var tracks = Tracks.GetTracksInArtist(artist.Id); + var tracks = Tracks.GetTracksInArtist(_artist.Id); Tracks.Get(tracks.First().Id).Should().NotBeNull(); } @@ -50,7 +49,7 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_be_able_to_set_monitor_status() { - var tracks = Tracks.GetTracksInArtist(artist.Id); + var tracks = Tracks.GetTracksInArtist(_artist.Id); var updatedTrack = tracks.First(); updatedTrack.Monitored = false; @@ -61,7 +60,7 @@ namespace NzbDrone.Integration.Test.ApiTests [TearDown] public void TearDown() { - Artist.Delete(artist.Id); + Artist.Delete(_artist.Id); Thread.Sleep(2000); } }