mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix limit reverse issue
This commit is contained in:
parent
fbe624ca6d
commit
ef3e4dc39b
@ -147,10 +147,12 @@ namespace Kyoo.Core.Controllers
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default)
|
||||
{
|
||||
ICollection<LibraryItem> items = await ApplyFilters(_LibraryRelatedQuery(x => x.ID == id),
|
||||
ICollection<LibraryItem> items = await ApplyFilters(
|
||||
_LibraryRelatedQuery(x => x.ID == id),
|
||||
where,
|
||||
sort,
|
||||
limit);
|
||||
limit
|
||||
);
|
||||
if (!items.Any() && await _libraries.Value.GetOrDefault(id) == null)
|
||||
throw new ItemNotFoundException();
|
||||
return items;
|
||||
@ -162,10 +164,12 @@ namespace Kyoo.Core.Controllers
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default)
|
||||
{
|
||||
ICollection<LibraryItem> items = await ApplyFilters(_LibraryRelatedQuery(x => x.Slug == slug),
|
||||
ICollection<LibraryItem> items = await ApplyFilters(
|
||||
_LibraryRelatedQuery(x => x.Slug == slug),
|
||||
where,
|
||||
sort,
|
||||
limit);
|
||||
limit
|
||||
);
|
||||
if (!items.Any() && await _libraries.Value.GetOrDefault(slug) == null)
|
||||
throw new ItemNotFoundException();
|
||||
return items;
|
||||
|
@ -140,6 +140,8 @@ namespace Kyoo.Core.Controllers
|
||||
T reference,
|
||||
bool next = true)
|
||||
{
|
||||
sort ??= DefaultSort;
|
||||
|
||||
// x =>
|
||||
ParameterExpression x = Expression.Parameter(typeof(T), "x");
|
||||
ConstantExpression referenceC = Expression.Constant(reference, typeof(T));
|
||||
@ -284,12 +286,14 @@ namespace Kyoo.Core.Controllers
|
||||
if (where != null)
|
||||
query = query.Where(where);
|
||||
|
||||
if (limit.AfterID != null)
|
||||
if (limit?.AfterID != null)
|
||||
{
|
||||
T reference = await Get(limit.AfterID.Value);
|
||||
query = query.Where(KeysetPaginatate(sort, reference, !limit.Reverse));
|
||||
}
|
||||
if (limit.Limit > 0)
|
||||
if (limit?.Reverse == true)
|
||||
query = query.Reverse();
|
||||
if (limit?.Limit > 0)
|
||||
query = query.Take(limit.Limit);
|
||||
|
||||
return await query.ToListAsync();
|
||||
|
@ -57,7 +57,7 @@ namespace Kyoo.Core
|
||||
context.Result = new ConflictObjectResult(ex.Existing);
|
||||
break;
|
||||
case Exception ex:
|
||||
_logger.LogError("Unhandled error", ex);
|
||||
_logger.LogError(ex, "Unhandled error");
|
||||
context.Result = new ServerErrorObjectResult(new RequestError("Internal Server Error"));
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user