Fixed Delete Series + Issue Covers from Kavita+ (#3784)

This commit is contained in:
Joe Milazzo 2025-05-03 13:46:40 -06:00 committed by GitHub
parent 3a0d33ca13
commit bc41b0256e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2189 additions and 1596 deletions

View file

@ -8,6 +8,7 @@ using API.DTOs.Reader;
using API.DTOs.SeriesDetail;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Metadata;
using API.Extensions;
using API.Extensions.QueryExtensions;
using AutoMapper;
@ -27,6 +28,7 @@ public enum ChapterIncludes
Genres = 16,
Tags = 32,
ExternalReviews = 1 << 6,
ExternalRatings = 1 << 7
}
public interface IChapterRepository
@ -51,8 +53,10 @@ public interface IChapterRepository
IEnumerable<Chapter> GetChaptersForSeries(int seriesId);
Task<IList<Chapter>> GetAllChaptersForSeries(int seriesId);
Task<int> GetAverageUserRating(int chapterId, int userId);
Task<IList<UserReviewDto>> GetExternalChapterReviews(int chapterId);
Task<IList<RatingDto>> GetExternalChapterRatings(int chapterId);
Task<IList<UserReviewDto>> GetExternalChapterReviewDtos(int chapterId);
Task<IList<ExternalReview>> GetExternalChapterReview(int chapterId);
Task<IList<RatingDto>> GetExternalChapterRatingDtos(int chapterId);
Task<IList<ExternalRating>> GetExternalChapterRatings(int chapterId);
}
public class ChapterRepository : IChapterRepository
{
@ -332,7 +336,7 @@ public class ChapterRepository : IChapterRepository
return avg.HasValue ? (int) (avg.Value * 20) : 0;
}
public async Task<IList<UserReviewDto>> GetExternalChapterReviews(int chapterId)
public async Task<IList<UserReviewDto>> GetExternalChapterReviewDtos(int chapterId)
{
return await _context.Chapter
.Where(c => c.Id == chapterId)
@ -342,7 +346,15 @@ public class ChapterRepository : IChapterRepository
.ToListAsync();
}
public async Task<IList<RatingDto>> GetExternalChapterRatings(int chapterId)
public async Task<IList<ExternalReview>> GetExternalChapterReview(int chapterId)
{
return await _context.Chapter
.Where(c => c.Id == chapterId)
.SelectMany(c => c.ExternalReviews)
.ToListAsync();
}
public async Task<IList<RatingDto>> GetExternalChapterRatingDtos(int chapterId)
{
return await _context.Chapter
.Where(c => c.Id == chapterId)
@ -350,4 +362,12 @@ public class ChapterRepository : IChapterRepository
.ProjectTo<RatingDto>(_mapper.ConfigurationProvider)
.ToListAsync();
}
public async Task<IList<ExternalRating>> GetExternalChapterRatings(int chapterId)
{
return await _context.Chapter
.Where(c => c.Id == chapterId)
.SelectMany(c => c.ExternalRatings)
.ToListAsync();
}
}

View file

@ -57,6 +57,8 @@ public enum SeriesIncludes
ExternalRatings = 128,
ExternalRecommendations = 256,
ExternalMetadata = 512,
ExternalData = ExternalMetadata | ExternalReviews | ExternalRatings | ExternalRecommendations,
}
/// <summary>
@ -563,7 +565,13 @@ public class SeriesRepository : ISeriesRepository
if (!fullSeries) return await query.ToListAsync();
return await query.Include(s => s.Volumes)
return await query
.Include(s => s.Volumes)
.ThenInclude(v => v.Chapters)
.ThenInclude(c => c.ExternalRatings)
.Include(s => s.Volumes)
.ThenInclude(v => v.Chapters)
.ThenInclude(c => c.ExternalReviews)
.Include(s => s.Relations)
.Include(s => s.Metadata)