Revert "Unify ChapterRating with Rating"
This wasn't working out, there is still some duplicate code. But not that much, and from the API, there is no different. Hooray!
This commit is contained in:
parent
052b3f9fe4
commit
184cf46533
21 changed files with 389 additions and 87 deletions
|
|
@ -315,14 +315,14 @@ public class ChapterRepository : IChapterRepository
|
|||
public async Task<int> GetAverageUserRating(int chapterId, int userId)
|
||||
{
|
||||
// If there is 0 or 1 rating and that rating is you, return 0 back
|
||||
var countOfRatingsThatAreUser = await _context.AppUserRating
|
||||
var countOfRatingsThatAreUser = await _context.AppUserChapterRating
|
||||
.Where(r => r.ChapterId == chapterId && r.HasBeenRated)
|
||||
.CountAsync(u => u.AppUserId == userId);
|
||||
if (countOfRatingsThatAreUser == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var avg = (await _context.AppUserRating
|
||||
var avg = (await _context.AppUserChapterRating
|
||||
.Where(r => r.ChapterId == chapterId && r.HasBeenRated)
|
||||
.AverageAsync(r => (int?) r.Rating));
|
||||
return avg.HasValue ? (int) (avg.Value * 20) : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue