mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-03 19:17:05 -05:00 
			
		
		
		
	* Added a migration for existing ratings * Fixed duplicating web links and changed so it has the see more functionality. * One more unit test
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Linq;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using Microsoft.EntityFrameworkCore;
 | 
						|
using Microsoft.Extensions.Logging;
 | 
						|
 | 
						|
namespace API.Data.ManualMigrations;
 | 
						|
 | 
						|
/// <summary>
 | 
						|
/// Introduced in v0.7.5.6 and v0.7.6, Ratings > 0 need to have "HasRatingSet"
 | 
						|
/// </summary>
 | 
						|
/// <remarks>Added in v0.7.5.6</remarks>
 | 
						|
// ReSharper disable once InconsistentNaming
 | 
						|
public static class MigrateExistingRatings
 | 
						|
{
 | 
						|
    public static async Task Migrate(DataContext context, ILogger<Program> logger)
 | 
						|
    {
 | 
						|
        logger.LogCritical("Running MigrateExistingRatings migration - Please be patient, this may take some time. This is not an error");
 | 
						|
 | 
						|
        foreach (var r in context.AppUserRating.Where(r => r.Rating > 0f))
 | 
						|
        {
 | 
						|
            r.HasBeenRated = true;
 | 
						|
            context.Entry(r).State = EntityState.Modified;
 | 
						|
        }
 | 
						|
 | 
						|
        if (context.ChangeTracker.HasChanges())
 | 
						|
        {
 | 
						|
            await context.SaveChangesAsync();
 | 
						|
        }
 | 
						|
 | 
						|
        logger.LogCritical("Running MigrateExistingRatings migration - Completed. This is not an error");
 | 
						|
    }
 | 
						|
}
 |