mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-05-21 07:06:33 -04:00
Almost there (#4343)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using API.Entities;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Extensions.QueryExtensions;
|
||||
|
||||
@@ -9,16 +10,17 @@ public static class ChapterQueryExtensions
|
||||
public static IOrderedQueryable<Chapter> ApplyDefaultChapterOrdering(this IQueryable<Chapter> query)
|
||||
{
|
||||
return query
|
||||
.Include(c => c.Volume)
|
||||
.OrderBy(c =>
|
||||
// Priority 1: Regular volumes (not loose leaf, not special)
|
||||
c.Volume.Number == Parser.LooseLeafVolumeNumber ||
|
||||
c.Volume.Number == Parser.SpecialVolumeNumber ? 1 : 0)
|
||||
// Priority 1: Regular volumes (not loose-leaf, not special)
|
||||
c.Volume.MinNumber == Parser.LooseLeafVolumeNumber ||
|
||||
c.Volume.MinNumber == Parser.SpecialVolumeNumber ? 1 : 0)
|
||||
.ThenBy(c =>
|
||||
// Priority 2: Loose leaf over specials
|
||||
c.Volume.Number == Parser.SpecialVolumeNumber ? 1 : 0)
|
||||
c.Volume.MinNumber == Parser.SpecialVolumeNumber ? 1 : 0)
|
||||
// Priority 3: Non-special chapters
|
||||
.ThenBy(c => c.IsSpecial ? 1 : 0)
|
||||
.ThenBy(c => c.Volume.Number)
|
||||
.ThenBy(c => c.Volume.MinNumber)
|
||||
.ThenBy(c => c.SortOrder);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user