mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-05-21 07:06:33 -04:00
Last of the Year - Page Offset, Device-bound Reading Profiles, and more! (#4313)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: DieselTech <30128380+DieselTech@users.noreply.github.com> Co-authored-by: Alex George <xzeroknightx@gmail.com> Co-authored-by: Lucas Winther <lucasw89@live.dk> Co-authored-by: Toni Kielo <toni.kielo@gmail.com> Co-authored-by: Patrick Orave <oravep@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using API.DTOs.Filtering;
|
||||
using API.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -36,6 +36,8 @@ public static class SeriesSort
|
||||
.Max(), sortOptions),
|
||||
SortField.AverageRating => query.DoOrderBy(s => s.ExternalSeriesMetadata.ExternalRatings
|
||||
.Where(p => p.SeriesId == s.Id).Average(p => p.AverageScore), sortOptions),
|
||||
SortField.UserRating => query.DoOrderBy(s => s.Ratings.Where(r => r.SeriesId == s.Id && r.AppUserId == userId).Max(r => r.Rating), sortOptions)
|
||||
.ThenBy(s => s.SortName.ToLower()),
|
||||
SortField.Random => query.DoOrderBy(s => EF.Functions.Random(), sortOptions),
|
||||
_ => query
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
@@ -350,7 +350,7 @@ public static class QueryableExtensions
|
||||
/// <param name="keySelector"></param>
|
||||
/// <param name="sortOptions"></param>
|
||||
/// <returns></returns>
|
||||
public static IQueryable<T> DoOrderBy<T, TKey>(this IQueryable<T> query, Expression<Func<T, TKey>> keySelector, SortOptions sortOptions)
|
||||
public static IOrderedQueryable<T> DoOrderBy<T, TKey>(this IQueryable<T> query, Expression<Func<T, TKey>> keySelector, SortOptions sortOptions)
|
||||
{
|
||||
return sortOptions.IsAscending ? query.OrderBy(keySelector) : query.OrderByDescending(keySelector);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user