diff --git a/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs b/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs index cc741a0c4..f3c38e80d 100644 --- a/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/AuthorRepository.cs @@ -13,6 +13,7 @@ public interface IAuthorRepository : IBasicRepository Author FindByName(string cleanName); Author FindById(string foreignAuthorId); Dictionary AllAuthorPaths(); + Dictionary> AllAuthorTags(); Author GetAuthorByMetadataId(int authorMetadataId); List GetAuthorsByMetadataId(IEnumerable authorMetadataId); } @@ -65,6 +66,15 @@ public Dictionary AllAuthorPaths() } } + public Dictionary> AllAuthorTags() + { + using (var conn = _database.OpenConnection()) + { + var strSql = "SELECT \"Id\" AS \"Key\", \"Tags\" AS \"Value\" FROM \"Authors\" WHERE \"Tags\" IS NOT NULL"; + return conn.Query>>(strSql).ToDictionary(x => x.Key, x => x.Value); + } + } + public Author GetAuthorByMetadataId(int authorMetadataId) { return Query(s => s.AuthorMetadataId == authorMetadataId).SingleOrDefault(); diff --git a/src/NzbDrone.Core/Books/Services/AuthorService.cs b/src/NzbDrone.Core/Books/Services/AuthorService.cs index b0a5515b2..372ef218c 100644 --- a/src/NzbDrone.Core/Books/Services/AuthorService.cs +++ b/src/NzbDrone.Core/Books/Services/AuthorService.cs @@ -24,6 +24,7 @@ public interface IAuthorService List GetReportCandidates(string reportTitle); void DeleteAuthor(int authorId, bool deleteFiles, bool addImportListExclusion = false); List GetAllAuthors(); + Dictionary> GetAllAuthorTags(); List AllForTag(int tagId); Author UpdateAuthor(Author author); List UpdateAuthors(List authors, bool useExistingRelativeFolder); @@ -185,6 +186,11 @@ public List GetAllAuthors() return _cache.Get("GetAllAuthors", () => _authorRepository.All().ToList(), TimeSpan.FromSeconds(30)); } + public Dictionary> GetAllAuthorTags() + { + return _authorRepository.AllAuthorTags(); + } + public Dictionary AllAuthorPaths() { return _authorRepository.AllAuthorPaths(); diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs index dbee84331..5fa50dfcc 100644 --- a/src/NzbDrone.Core/Tags/TagService.cs +++ b/src/NzbDrone.Core/Tags/TagService.cs @@ -106,7 +106,7 @@ public List Details() var importLists = _importListFactory.All(); var notifications = _notificationFactory.All(); var restrictions = _releaseProfileService.All(); - var authors = _authorService.GetAllAuthors(); + var authors = _authorService.GetAllAuthorTags(); var indexers = _indexerService.All(); var rootFolders = _rootFolderService.All(); @@ -122,7 +122,7 @@ public List Details() 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(), - AuthorIds = authors.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), + AuthorIds = authors.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(), RootFolderIds = rootFolders.Where(c => c.DefaultTags.Contains(tag.Id)).Select(c => c.Id).ToList() });