Fixed a bug with user reviews (#2677)

This commit is contained in:
Joe Milazzo 2024-02-01 14:30:44 -06:00 committed by GitHub
parent 828d62dfe9
commit a9ab84803e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 10 deletions

View file

@ -207,7 +207,7 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
if (user == null) return Unauthorized();
var userReviews = (await unitOfWork.UserRepository.GetUserRatingDtosForSeriesAsync(seriesId, user.Id))
.Where(r => !string.IsNullOrEmpty(r.Body))
.Where(r => !string.IsNullOrEmpty(r.BodyJustText))
.OrderByDescending(review => review.Username.Equals(user.UserName) ? 1 : 0)
.ToList();
@ -221,7 +221,13 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
}
var ret = await metadataService.GetSeriesDetail(user.Id, seriesId);
if (ret == null) return Ok(null);
if (ret == null) return Ok(new SeriesDetailPlusDto()
{
Reviews = userReviews,
Recommendations = null,
Ratings = null
});
await _cacheProvider.SetAsync(cacheKey, ret, TimeSpan.FromHours(48));
// For some reason if we don't use a different instance, the cache keeps changes made below