Some cleanup. There is a bug around cover image not working for chapter image due to overwriting current and not using a temp image.

This commit is contained in:
Joseph Milazzo 2025-05-01 06:27:01 -05:00
parent 01f9cea86f
commit eb1a524b2f
6 changed files with 47 additions and 18 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;
@ -51,8 +52,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 +335,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 +345,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 +361,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();
}
}