From 2f8af9f8e69a72b1b01b38af605688c17b6a8b45 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Fri, 30 Jul 2021 09:02:17 -0500 Subject: [PATCH] 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 --- .github/workflows/nightly-docker.yml | 10 +++++----- API/Data/SeriesRepository.cs | 19 +++++-------------- Kavita.Common/Kavita.Common.csproj | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index 680015afe..9df2375cb 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -28,7 +28,7 @@ jobs: echo 'Copying back to Kavita wwwroot' rsync -a dist/ ../../API/wwwroot/ - + cd ../ || exit - name: Get csproj Version @@ -38,14 +38,14 @@ jobs: proj-path: Kavita.Common/Kavita.Common.csproj - name: Echo csproj version - run: echo "${{steps.get-version.outputs.assembly-version}}" + run: echo "${{steps.get-version.outputs.assembly-version}}" - name: Compile dotnet app uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.x' - run: ./monorepo-build.sh - + - name: Trigger Sentry workflow uses: benc-uk/workflow-dispatch@v1 with: @@ -77,12 +77,12 @@ jobs: - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} - + - name: Notify Discord 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 }} diff --git a/API/Data/SeriesRepository.cs b/API/Data/SeriesRepository.cs index 7a608882a..92d19042b 100644 --- a/API/Data/SeriesRepository.cs +++ b/API/Data/SeriesRepository.cs @@ -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(_mapper.ConfigurationProvider) + .AsSplitQuery() .AsNoTracking(); - // var retSeries = series - // .OrderByDescending(s => s.LastModified) - // .Select(s => s.Series) - // .ProjectTo(_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.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize); } public async Task GetSeriesMetadata(int seriesId) diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index d099ff6ea..fbba64189 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -4,7 +4,7 @@ net5.0 kavitareader.com Kavita - 0.4.3.7 + 0.4.3.8 en