diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs index 909dd039c..8e28e3f35 100644 --- a/src/NzbDrone.Core/Tags/TagService.cs +++ b/src/NzbDrone.Core/Tags/TagService.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Tags var importLists = _importListFactory.All(); var notifications = _notificationFactory.All(); var restrictions = _releaseProfileService.All(); - var series = _seriesService.GetAllSeries(); + var series = _seriesService.GetAllSeriesTags(); var indexers = _indexerService.All(); var autotags = _autoTaggingService.All(); @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Tags ImportListIds = importLists.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), - SeriesIds = series.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), + SeriesIds = series.Where(c => c.Value.Contains(tag.Id)).Select(c => c.Key).ToList(), IndexerIds = indexers.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), AutoTagIds = autotags.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), }); diff --git a/src/NzbDrone.Core/Tv/SeriesRepository.cs b/src/NzbDrone.Core/Tv/SeriesRepository.cs index 7227cf2a9..9613395f5 100644 --- a/src/NzbDrone.Core/Tv/SeriesRepository.cs +++ b/src/NzbDrone.Core/Tv/SeriesRepository.cs @@ -17,6 +17,7 @@ namespace NzbDrone.Core.Tv Series FindByPath(string path); List AllSeriesTvdbIds(); Dictionary AllSeriesPaths(); + Dictionary> AllSeriesTags(); } public class SeriesRepository : BasicRepository, ISeriesRepository @@ -90,6 +91,15 @@ namespace NzbDrone.Core.Tv } } + public Dictionary> AllSeriesTags() + { + using (var conn = _database.OpenConnection()) + { + var strSql = "SELECT Id AS [Key], Tags AS [Value] FROM Series WHERE Tags IS NOT NULL"; + return conn.Query>>(strSql).ToDictionary(x => x.Key, x => x.Value); + } + } + private Series ReturnSingleSeriesOrThrow(List series) { if (series.Count == 0) diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs index 864eba357..6fd4551cf 100644 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ b/src/NzbDrone.Core/Tv/SeriesService.cs @@ -24,6 +24,7 @@ namespace NzbDrone.Core.Tv List GetAllSeries(); List AllSeriesTvdbIds(); Dictionary GetAllSeriesPaths(); + Dictionary> GetAllSeriesTags(); List AllForTag(int tagId); Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true, bool publishUpdatedEvent = true); List UpdateSeries(List series, bool useExistingRelativeFolder); @@ -169,6 +170,11 @@ namespace NzbDrone.Core.Tv return _seriesRepository.AllSeriesPaths(); } + public Dictionary> GetAllSeriesTags() + { + return _seriesRepository.AllSeriesTags(); + } + public List AllForTag(int tagId) { return GetAllSeries().Where(s => s.Tags.Contains(tagId))