Overall Ratings (#2129)
* Corrected tooltip for Cache * Ensure we sync the DB to what's in appsettings.json for Cache key. * Change the fingerprinting method for Windows installs exclusively to avoid churn due to how security updates are handled. * Hooked up the ability to see where reviews are from via an icon on the review card, rather than having to click or know that MAL has "external Review" as title. * Updated FAQ for Kavita+ to link directly to the FAQ * Added the ability for all ratings on a series to be shown to the user. Added favorite count on AL and MAL * Cleaned up so the check for Kavita+ license doesn't seem like it's running when no license is registered. * Tweaked the test instance buy link to test new product.
This commit is contained in:
parent
34f828e750
commit
49daca943e
29 changed files with 231 additions and 56 deletions
|
@ -135,8 +135,8 @@ public interface ISeriesRepository
|
|||
Task<IDictionary<int, int>> GetLibraryIdsForSeriesAsync();
|
||||
Task<IList<SeriesMetadataDto>> GetSeriesMetadataForIds(IEnumerable<int> seriesIds);
|
||||
Task<IList<Series>> GetAllWithCoversInDifferentEncoding(EncodeFormat encodeFormat, bool customOnly = true);
|
||||
|
||||
Task<SeriesDto?> GetSeriesDtoByNamesAndMetadataIdsForUser(int userId, IEnumerable<string> names, LibraryType libraryType, string aniListUrl, string malUrl);
|
||||
Task<int> GetAverageUserRating(int seriesId);
|
||||
}
|
||||
|
||||
public class SeriesRepository : ISeriesRepository
|
||||
|
@ -1658,6 +1658,18 @@ public class SeriesRepository : ISeriesRepository
|
|||
.FirstOrDefaultAsync(); // Some users may have improperly configured libraries
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Average rating for all users within Kavita instance
|
||||
/// </summary>
|
||||
/// <param name="seriesId"></param>
|
||||
public async Task<int> GetAverageUserRating(int seriesId)
|
||||
{
|
||||
var avg = (await _context.AppUserRating
|
||||
.Where(r => r.SeriesId == seriesId)
|
||||
.AverageAsync(r => (int?) r.Rating));
|
||||
return avg.HasValue ? (int) avg.Value : 0;
|
||||
}
|
||||
|
||||
public async Task<bool> IsSeriesInWantToRead(int userId, int seriesId)
|
||||
{
|
||||
var libraryIds = await _context.Library.GetUserLibraries(userId).ToListAsync();
|
||||
|
|
|
@ -133,6 +133,8 @@ public static class Seed
|
|||
directoryService.CacheDirectory + string.Empty;
|
||||
context.ServerSetting.First(s => s.Key == ServerSettingKey.BackupDirectory).Value =
|
||||
DirectoryService.BackupDirectory + string.Empty;
|
||||
context.ServerSetting.First(s => s.Key == ServerSettingKey.CacheSize).Value =
|
||||
Configuration.CacheSize + string.Empty;
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue