Critical Progress Order Fix (#2477)

This commit is contained in:
Joe Milazzo 2023-12-05 06:31:59 -06:00 committed by GitHub
parent 36aa5c5a70
commit 980a123df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using API.Data.ManualMigrations;
using API.DTOs;
@ -218,15 +219,16 @@ public class AppUserProgressRepository : IAppUserProgressRepository
})
.AsEnumerable();
// Need to run this Raw because DataContext will update LastModified on the entity which breaks ordering for progress
var sqlBuilder = new StringBuilder();
foreach (var update in updates)
{
_context.AppUserProgresses
.Where(p => p.Id == update.ProgressId)
.ToList() // Execute the query to ensure exclusive lock
.ForEach(p => p.PagesRead = update.NewPagesRead);
sqlBuilder.Append($"UPDATE AppUserProgresses SET PagesRead = {update.NewPagesRead} WHERE Id = {update.ProgressId};");
}
await _context.SaveChangesAsync();
// Execute the batch SQL
var batchSql = sqlBuilder.ToString();
await _context.Database.ExecuteSqlRawAsync(batchSql);
}
#nullable enable

View File

@ -7,7 +7,7 @@
"name": "GPL-3.0",
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
},
"version": "0.7.10.20"
"version": "0.7.11.0"
},
"servers": [
{