OPDS Performance Enhancements (#4332)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo
2026-01-08 08:25:05 -07:00
committed by GitHub
parent 1480d20132
commit a7859e1a86
94 changed files with 4515 additions and 3124 deletions
@@ -0,0 +1,24 @@
using System.Linq;
using API.Entities;
using API.Services.Tasks.Scanner.Parser;
namespace API.Extensions.QueryExtensions;
public static class ChapterQueryExtensions
{
public static IOrderedQueryable<Chapter> ApplyDefaultChapterOrdering(this IQueryable<Chapter> query)
{
return query
.OrderBy(c =>
// Priority 1: Regular volumes (not loose leaf, not special)
c.Volume.Number == Parser.LooseLeafVolumeNumber ||
c.Volume.Number == Parser.SpecialVolumeNumber ? 1 : 0)
.ThenBy(c =>
// Priority 2: Loose leaf over specials
c.Volume.Number == Parser.SpecialVolumeNumber ? 1 : 0)
// Priority 3: Non-special chapters
.ThenBy(c => c.IsSpecial ? 1 : 0)
.ThenBy(c => c.Volume.Number)
.ThenBy(c => c.SortOrder);
}
}
@@ -0,0 +1,26 @@
using System.Linq;
using AutoMapper;
using AutoMapper.QueryableExtensions;
namespace API.Extensions.QueryExtensions;
public static class ProjectToExtensions
{
public static IQueryable<TDestination> ProjectToWithProgress<TSource, TDestination>(
this IQueryable<TSource> queryable,
IConfigurationProvider config,
int userId)
{
return queryable.ProjectTo<TDestination>(config, new { userId });
}
// Convenience overload taking IMapper directly
public static IQueryable<TDestination> ProjectToWithProgress<TSource, TDestination>(
this IQueryable<TSource> queryable,
IMapper mapper,
int userId)
{
return queryable.ProjectTo<TDestination>(mapper.ConfigurationProvider, new { userId });
}
}