mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
In Progress Activity Stream Fixes (#136)
* Fixed a bug in In-Progress where it wasn't properly fetching series.
This commit is contained in:
parent
667d1d2a4d
commit
ca5c666b7b
@ -302,22 +302,27 @@ 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 seriesWithProgress = _context.Series
|
||||||
|
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
|
||||||
|
{
|
||||||
|
Series = s,
|
||||||
|
PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id).Sum(s1 => s1.PagesRead),
|
||||||
|
progress.AppUserId,
|
||||||
|
progress.LastModified
|
||||||
|
})
|
||||||
|
.Where(s => s.AppUserId == userId
|
||||||
|
&& s.PagesRead > 0
|
||||||
|
&& s.PagesRead < s.Series.Pages
|
||||||
|
&& (libraryId <= 0 || s.Series.LibraryId == libraryId))
|
||||||
|
.Select(s => s.Series.Id);
|
||||||
|
|
||||||
|
|
||||||
var series = await _context.Series
|
var series = await _context.Series
|
||||||
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
|
.Where(s => seriesWithProgress.Contains(s.Id))
|
||||||
{
|
|
||||||
Series = s,
|
|
||||||
PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id).Sum(s1 => s1.PagesRead),
|
|
||||||
progress.AppUserId,
|
|
||||||
progress.LastModified
|
|
||||||
})
|
|
||||||
.Where(s => s.AppUserId == userId
|
|
||||||
&& s.PagesRead > 0
|
|
||||||
&& s.PagesRead < s.Series.Pages
|
|
||||||
&& (libraryId <= 0 || s.Series.LibraryId == libraryId) )
|
|
||||||
.Take(limit)
|
|
||||||
.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();
|
||||||
return series.DistinctBy(s => s.Name);
|
return series.DistinctBy(s => s.Name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user