mirror of
https://github.com/Readarr/Readarr
synced 2026-01-30 11:23:00 +01:00
Faster tag view in UI for large libraries
(cherry picked from commit b050e1d2eb3bff9e28e7a1545d121be091789308) Closes #2571
This commit is contained in:
parent
257d279e43
commit
10766dd227
3 changed files with 18 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ public interface IAuthorRepository : IBasicRepository<Author>
|
|||
Author FindByName(string cleanName);
|
||||
Author FindById(string foreignAuthorId);
|
||||
Dictionary<int, string> AllAuthorPaths();
|
||||
Dictionary<int, List<int>> AllAuthorTags();
|
||||
Author GetAuthorByMetadataId(int authorMetadataId);
|
||||
List<Author> GetAuthorsByMetadataId(IEnumerable<int> authorMetadataId);
|
||||
}
|
||||
|
|
@ -65,6 +66,15 @@ public Dictionary<int, string> AllAuthorPaths()
|
|||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, List<int>> 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<KeyValuePair<int, List<int>>>(strSql).ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public Author GetAuthorByMetadataId(int authorMetadataId)
|
||||
{
|
||||
return Query(s => s.AuthorMetadataId == authorMetadataId).SingleOrDefault();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public interface IAuthorService
|
|||
List<Author> GetReportCandidates(string reportTitle);
|
||||
void DeleteAuthor(int authorId, bool deleteFiles, bool addImportListExclusion = false);
|
||||
List<Author> GetAllAuthors();
|
||||
Dictionary<int, List<int>> GetAllAuthorTags();
|
||||
List<Author> AllForTag(int tagId);
|
||||
Author UpdateAuthor(Author author);
|
||||
List<Author> UpdateAuthors(List<Author> authors, bool useExistingRelativeFolder);
|
||||
|
|
@ -185,6 +186,11 @@ public List<Author> GetAllAuthors()
|
|||
return _cache.Get("GetAllAuthors", () => _authorRepository.All().ToList(), TimeSpan.FromSeconds(30));
|
||||
}
|
||||
|
||||
public Dictionary<int, List<int>> GetAllAuthorTags()
|
||||
{
|
||||
return _authorRepository.AllAuthorTags();
|
||||
}
|
||||
|
||||
public Dictionary<int, string> AllAuthorPaths()
|
||||
{
|
||||
return _authorRepository.AllAuthorPaths();
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public List<TagDetails> 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<TagDetails> 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()
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue