A few reading list bug fixes (#3663)

This commit is contained in:
Fesaa 2025-03-22 20:39:09 +01:00 committed by GitHub
parent 0785d4afab
commit a7e1386bad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 164 additions and 15 deletions

View file

@ -50,6 +50,14 @@ public interface IReadingListService
Task CreateReadingListsFromSeries(int libraryId, int seriesId);
Task<string> GenerateReadingListCoverImage(int readingListId);
/// <summary>
/// Check, and update if needed, all reading lists' AgeRating who contain the passed series
/// </summary>
/// <param name="seriesId">The series whose age rating is being updated</param>
/// <param name="ageRating">The new (uncommited) age rating of the series</param>
/// <returns></returns>
/// <remarks>This method does not commit changes</remarks>
Task UpdateReadingListAgeRatingForSeries(int seriesId, AgeRating ageRating);
}
/// <summary>
@ -96,7 +104,13 @@ public class ReadingListService : IReadingListService
{
title = $"Volume {Parser.CleanSpecialTitle(item.VolumeNumber)}";
}
} else {
}
else if (item.VolumeNumber == Parser.SpecialVolume)
{
title = specialTitle;
}
else
{
title = $"Volume {specialTitle}";
}
}
@ -844,4 +858,22 @@ public class ReadingListService : IReadingListService
return !_directoryService.FileSystem.File.Exists(destFile) ? string.Empty : destFile;
}
public async Task UpdateReadingListAgeRatingForSeries(int seriesId, AgeRating ageRating)
{
var readingLists = await _unitOfWork.ReadingListRepository.GetReadingListsBySeriesId(seriesId);
foreach (var readingList in readingLists)
{
var seriesIds = readingList.Items.Select(item => item.SeriesId).ToList();
seriesIds.Remove(seriesId); // Don't get AgeRating from database
var maxAgeRating = await _unitOfWork.SeriesRepository.GetMaxAgeRatingFromSeriesAsync(seriesIds);
if (ageRating > maxAgeRating)
{
maxAgeRating = ageRating;
}
readingList.AgeRating = maxAgeRating;
}
}
}