Bugfixes + Potential iOS Webtoon Reader Fix (#2650)

This commit is contained in:
Joe Milazzo 2024-01-25 11:09:44 -06:00 committed by GitHub
parent 56fa393cf0
commit f660a1cd06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 157 additions and 197 deletions

View file

@ -8,6 +8,7 @@ using API.Data;
using API.DTOs;
using API.DTOs.Filtering;
using API.DTOs.Metadata;
using API.DTOs.Recommendation;
using API.DTOs.SeriesDetail;
using API.Entities.Enums;
using API.Extensions;
@ -207,13 +208,18 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
.OrderByDescending(review => review.Username.Equals(user.UserName) ? 1 : 0)
.ToList();
var cacheKey = CacheKey + seriesId + "_" + user.Id;
var cacheKey = CacheKey + seriesId;
var results = await _cacheProvider.GetAsync<SeriesDetailPlusDto>(cacheKey);
if (results.HasValue)
{
var cachedResult = results.Value;
userReviews.AddRange(cachedResult.Reviews);
cachedResult.Reviews = ReviewService.SelectSpectrumOfReviews(userReviews);
if (!await unitOfWork.UserRepository.IsUserAdminAsync(user))
{
cachedResult.Recommendations.ExternalSeries = new List<ExternalSeriesDto>();
}
return cachedResult;
}
@ -221,10 +227,13 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
if (ret == null) return Ok(null);
userReviews.AddRange(ret.Reviews);
ret.Reviews = ReviewService.SelectSpectrumOfReviews(userReviews);
await _cacheProvider.SetAsync(cacheKey, ret, TimeSpan.FromHours(24));
if (!await unitOfWork.UserRepository.IsUserAdminAsync(user))
{
ret.Recommendations.ExternalSeries = new List<ExternalSeriesDto>();
}
return Ok(ret);
}