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
|
|
@ -43,6 +43,7 @@ public enum AppUserIncludes
|
|||
SideNavStreams = 4096,
|
||||
ExternalSources = 8192,
|
||||
Collections = 16384, // 2^14
|
||||
ChapterRatings = 1 << 15,
|
||||
}
|
||||
|
||||
public interface IUserRepository
|
||||
|
|
@ -64,7 +65,8 @@ public interface IUserRepository
|
|||
Task<IEnumerable<AppUser>> GetAdminUsersAsync();
|
||||
Task<bool> IsUserAdminAsync(AppUser? user);
|
||||
Task<IList<string>> GetRoles(int userId);
|
||||
Task<AppUserRating?> GetUserRatingAsync(int seriesId, int userId, int? chapterId = null);
|
||||
Task<AppUserRating?> GetUserRatingAsync(int seriesId, int userId);
|
||||
Task<AppUserChapterRating?> GetUserChapterRatingAsync(int userId, int chapterId);
|
||||
Task<IList<UserReviewDto>> GetUserRatingDtosForSeriesAsync(int seriesId, int userId);
|
||||
Task<IList<UserReviewDto>> GetUserRatingDtosForChapterAsync(int chapterId, int userId);
|
||||
Task<AppUserPreferences?> GetPreferencesAsync(string username);
|
||||
|
|
@ -584,10 +586,17 @@ public class UserRepository : IUserRepository
|
|||
return await _userManager.GetRolesAsync(user);
|
||||
}
|
||||
|
||||
public async Task<AppUserRating?> GetUserRatingAsync(int seriesId, int userId, int? chapterId = null)
|
||||
public async Task<AppUserRating?> GetUserRatingAsync(int seriesId, int userId)
|
||||
{
|
||||
return await _context.AppUserRating
|
||||
.Where(r => r.SeriesId == seriesId && r.AppUserId == userId && r.ChapterId == chapterId)
|
||||
.Where(r => r.SeriesId == seriesId && r.AppUserId == userId)
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserChapterRating?> GetUserChapterRatingAsync(int userId, int chapterId)
|
||||
{
|
||||
return await _context.AppUserChapterRating
|
||||
.Where(r => r.AppUserId == userId && r.ChapterId == chapterId)
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
|
@ -595,7 +604,7 @@ public class UserRepository : IUserRepository
|
|||
{
|
||||
return await _context.AppUserRating
|
||||
.Include(r => r.AppUser)
|
||||
.Where(r => r.SeriesId == seriesId && r.ChapterId == null)
|
||||
.Where(r => r.SeriesId == seriesId)
|
||||
.Where(r => r.AppUser.UserPreferences.ShareReviews || r.AppUserId == userId)
|
||||
.OrderBy(r => r.AppUserId == userId)
|
||||
.ThenBy(r => r.Rating)
|
||||
|
|
@ -606,7 +615,7 @@ public class UserRepository : IUserRepository
|
|||
|
||||
public async Task<IList<UserReviewDto>> GetUserRatingDtosForChapterAsync(int chapterId, int userId)
|
||||
{
|
||||
return await _context.AppUserRating
|
||||
return await _context.AppUserChapterRating
|
||||
.Include(r => r.AppUser)
|
||||
.Where(r => r.ChapterId == chapterId)
|
||||
.Where(r => r.AppUser.UserPreferences.ShareReviews || r.AppUserId == userId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue