Performance Improvements (#2449)
This commit is contained in:
parent
419a827d42
commit
5ed1eebd26
34 changed files with 389 additions and 132 deletions
|
@ -33,6 +33,9 @@ public interface ICollectionTagRepository
|
|||
void Update(CollectionTag tag);
|
||||
Task<int> RemoveTagsWithoutSeries();
|
||||
Task<IEnumerable<CollectionTag>> GetAllTagsAsync(CollectionTagIncludes includes = CollectionTagIncludes.None);
|
||||
|
||||
Task<IEnumerable<CollectionTag>> GetAllTagsByNamesAsync(IEnumerable<string> normalizedTitles,
|
||||
CollectionTagIncludes includes = CollectionTagIncludes.None);
|
||||
Task<IList<string>> GetAllCoverImagesAsync();
|
||||
Task<bool> TagExists(string title);
|
||||
Task<IList<CollectionTag>> GetAllWithCoversInDifferentEncoding(EncodeFormat encodeFormat);
|
||||
|
@ -87,6 +90,15 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CollectionTag>> GetAllTagsByNamesAsync(IEnumerable<string> normalizedTitles, CollectionTagIncludes includes = CollectionTagIncludes.None)
|
||||
{
|
||||
return await _context.CollectionTag
|
||||
.Where(c => normalizedTitles.Contains(c.NormalizedTitle))
|
||||
.OrderBy(c => c.NormalizedTitle)
|
||||
.Includes(includes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<string?> GetCoverImageAsync(int collectionTagId)
|
||||
{
|
||||
return await _context.CollectionTag
|
||||
|
|
|
@ -17,6 +17,7 @@ public interface IGenreRepository
|
|||
void Remove(Genre genre);
|
||||
Task<Genre?> FindByNameAsync(string genreName);
|
||||
Task<IList<Genre>> GetAllGenresAsync();
|
||||
Task<IList<Genre>> GetAllGenresByNamesAsync(IEnumerable<string> normalizedNames);
|
||||
Task<IList<GenreTagDto>> GetAllGenreDtosAsync(int userId);
|
||||
Task RemoveAllGenreNoLongerAssociated(bool removeExternal = false);
|
||||
Task<IList<GenreTagDto>> GetAllGenreDtosForLibrariesAsync(IList<int> libraryIds, int userId);
|
||||
|
@ -96,6 +97,13 @@ public class GenreRepository : IGenreRepository
|
|||
return await _context.Genre.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<Genre>> GetAllGenresByNamesAsync(IEnumerable<string> normalizedNames)
|
||||
{
|
||||
return await _context.Genre
|
||||
.Where(g => normalizedNames.Contains(g.NormalizedTitle))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<GenreTagDto>> GetAllGenreDtosAsync(int userId)
|
||||
{
|
||||
var ageRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
|
|
@ -23,6 +23,7 @@ public interface IPersonRepository
|
|||
Task<IList<PersonDto>> GetAllPeopleDtosForLibrariesAsync(List<int> libraryIds, int userId);
|
||||
Task<int> GetCountAsync();
|
||||
|
||||
Task<IList<Person>> GetAllPeopleByRoleAndNames(PersonRole role, IEnumerable<string> normalizeNames);
|
||||
}
|
||||
|
||||
public class PersonRepository : IPersonRepository
|
||||
|
@ -80,6 +81,13 @@ public class PersonRepository : IPersonRepository
|
|||
return await _context.Person.CountAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<Person>> GetAllPeopleByRoleAndNames(PersonRole role, IEnumerable<string> normalizeNames)
|
||||
{
|
||||
return await _context.Person
|
||||
.Where(p => p.Role == role && normalizeNames.Contains(p.NormalizedName))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<IList<Person>> GetAllPeople()
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ using API.DTOs.Dashboard;
|
|||
using API.DTOs.Filtering;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Reader;
|
||||
using API.DTOs.ReadingLists;
|
||||
using API.DTOs.Search;
|
||||
using API.DTOs.SeriesDetail;
|
||||
|
@ -374,6 +375,33 @@ public class SeriesRepository : ISeriesRepository
|
|||
.ProjectTo<SearchResultDto>(_mapper.ConfigurationProvider)
|
||||
.AsEnumerable();
|
||||
|
||||
result.Bookmarks = (await _context.AppUserBookmark
|
||||
.Join(
|
||||
_context.Series,
|
||||
bookmark => bookmark.SeriesId,
|
||||
series => series.Id,
|
||||
(bookmark, series) => new {Bookmark = bookmark, Series = series}
|
||||
)
|
||||
.Where(joined => joined.Bookmark.AppUserId == userId &&
|
||||
(EF.Functions.Like(joined.Series.Name, $"%{searchQuery}%") ||
|
||||
(joined.Series.OriginalName != null &&
|
||||
EF.Functions.Like(joined.Series.OriginalName, $"%{searchQuery}%")) ||
|
||||
(joined.Series.LocalizedName != null &&
|
||||
EF.Functions.Like(joined.Series.LocalizedName, $"%{searchQuery}%"))))
|
||||
.OrderBy(joined => joined.Series.Name)
|
||||
.Take(maxRecords)
|
||||
.Select(joined => new BookmarkSearchResultDto()
|
||||
{
|
||||
SeriesName = joined.Series.Name,
|
||||
LocalizedSeriesName = joined.Series.LocalizedName,
|
||||
LibraryId = joined.Series.LibraryId,
|
||||
SeriesId = joined.Bookmark.SeriesId,
|
||||
ChapterId = joined.Bookmark.ChapterId,
|
||||
VolumeId = joined.Bookmark.VolumeId
|
||||
})
|
||||
.ToListAsync()).DistinctBy(s => s.SeriesId);
|
||||
|
||||
|
||||
result.ReadingLists = await _context.ReadingList
|
||||
.Where(rl => rl.AppUserId == userId || rl.Promoted)
|
||||
.Where(rl => EF.Functions.Like(rl.Title, $"%{searchQuery}%"))
|
||||
|
|
|
@ -16,6 +16,7 @@ public interface ITagRepository
|
|||
void Attach(Tag tag);
|
||||
void Remove(Tag tag);
|
||||
Task<IList<Tag>> GetAllTagsAsync();
|
||||
Task<IList<Tag>> GetAllTagsByNameAsync(IEnumerable<string> normalizedNames);
|
||||
Task<IList<TagDto>> GetAllTagDtosAsync(int userId);
|
||||
Task RemoveAllTagNoLongerAssociated();
|
||||
Task<IList<TagDto>> GetAllTagDtosForLibrariesAsync(IList<int> libraryIds, int userId);
|
||||
|
@ -76,6 +77,13 @@ public class TagRepository : ITagRepository
|
|||
return await _context.Tag.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<Tag>> GetAllTagsByNameAsync(IEnumerable<string> normalizedNames)
|
||||
{
|
||||
return await _context.Tag
|
||||
.Where(t => normalizedNames.Contains(t.NormalizedTitle))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<TagDto>> GetAllTagDtosAsync(int userId)
|
||||
{
|
||||
var userRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue