Fixed the In progress API returning back series that didn't belong (#453)

* Fixed the In progress API returning back series that had another users progress on them. Added SplitQuery which speeds up query significantly.

* Try out putting PR body into notification
This commit is contained in:
Joseph Milazzo 2021-07-30 09:02:17 -05:00 committed by GitHub
parent 1ec8f6235f
commit 2f8af9f8e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 20 deletions

View File

@ -82,7 +82,7 @@ jobs:
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
description:
description: ${{ github.event.body }}
details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated'
text: A new nightly build has been released for docker.
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}

View File

@ -370,32 +370,23 @@ namespace API.Data
.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),
PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id && s1.AppUserId == userId).Sum(s1 => s1.PagesRead),
progress.AppUserId,
LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id).Max(p => p.LastModified)
LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id && p.AppUserId == userId).Max(p => p.LastModified)
})
.AsNoTracking();
var retSeries = series.Where(s => s.AppUserId == userId
&& s.PagesRead > 0
&& s.PagesRead < s.Series.Pages
/*&& userLibraries.Contains(s.Series.LibraryId)*/
/* && formats.Contains(s.Series.Format) */)
&& s.PagesRead < s.Series.Pages)
.OrderByDescending(s => s.LastModified)
.Select(s => s.Series)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsSplitQuery()
.AsNoTracking();
// var retSeries = series
// .OrderByDescending(s => s.LastModified)
// .Select(s => s.Series)
// .ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
// .AsNoTracking();
// BUG: Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series
// Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series. See controller for pagination code
return await retSeries.ToListAsync();
//return await PagedList<SeriesDto>.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize);
}
public async Task<SeriesMetadataDto> GetSeriesMetadata(int seriesId)

View File

@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<Company>kavitareader.com</Company>
<Product>Kavita</Product>
<AssemblyVersion>0.4.3.7</AssemblyVersion>
<AssemblyVersion>0.4.3.8</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>