Merge branch 'develop' of https://github.com/Kareadita/Kavita into develop

This commit is contained in:
Joseph Milazzo 2021-03-31 16:43:31 -05:00
commit 480c990c1b

View File

@ -302,7 +302,8 @@ namespace API.Data
/// <returns></returns> /// <returns></returns>
public async Task<IEnumerable<SeriesDto>> GetInProgress(int userId, int libraryId, int limit) public async Task<IEnumerable<SeriesDto>> GetInProgress(int userId, int libraryId, int limit)
{ {
var series = await _context.Series
var seriesWithProgress = _context.Series
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new .Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
{ {
Series = s, Series = s,
@ -313,10 +314,14 @@ namespace API.Data
.Where(s => s.AppUserId == userId .Where(s => s.AppUserId == userId
&& s.PagesRead > 0 && s.PagesRead > 0
&& s.PagesRead < s.Series.Pages && s.PagesRead < s.Series.Pages
&& (libraryId <= 0 || s.Series.LibraryId == libraryId) ) && (libraryId <= 0 || s.Series.LibraryId == libraryId))
.Take(limit) .Select(s => s.Series.Id);
var series = await _context.Series
.Where(s => seriesWithProgress.Contains(s.Id))
.OrderByDescending(s => s.LastModified) .OrderByDescending(s => s.LastModified)
.Select(s => s.Series) .Take(limit)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider) .ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsNoTracking() .AsNoTracking()
.ToListAsync(); .ToListAsync();