[backend/masto-client] Move offset pagination into QueryableExtensions
This commit is contained in:
parent
961bda0164
commit
498ac154a7
2 changed files with 3 additions and 6 deletions
|
@ -133,7 +133,6 @@ public class SearchController(
|
|||
.Where(p => p.DisplayNameOrUsernameOrFqnContainsCaseInsensitive(search.Query!,
|
||||
config.Value.AccountDomain))
|
||||
.Where(p => !search.Following || p.IsFollowedBy(user))
|
||||
.Skip(pagination.Offset ?? 0)
|
||||
.Paginate(pagination, ControllerContext) //TODO: this will mess up our sorting
|
||||
.OrderByDescending(p => p.NotesCount)
|
||||
.RenderAllForMastodonAsync(userRenderer);
|
||||
|
@ -185,7 +184,6 @@ public class SearchController(
|
|||
.FilterByUser(search.UserId)
|
||||
.EnsureVisibleFor(user)
|
||||
.FilterHidden(user, db)
|
||||
.Skip(pagination.Offset ?? 0)
|
||||
.Paginate(pagination, ControllerContext)
|
||||
.PrecomputeVisibilities(user)
|
||||
.RenderAllForMastodonAsync(noteRenderer, user);
|
||||
|
@ -200,7 +198,6 @@ public class SearchController(
|
|||
{
|
||||
return await db.Hashtags
|
||||
.Where(p => EF.Functions.ILike(p.Name, "%" + EfHelpers.EscapeLikeQuery(search.Query!) + "%"))
|
||||
.Skip(pagination.Offset ?? 0)
|
||||
.Paginate(pagination, ControllerContext)
|
||||
.OrderByDescending(p => p.Id)
|
||||
.Select(p => new TagEntity
|
||||
|
|
|
@ -47,7 +47,7 @@ public static class QueryableExtensions
|
|||
_ => query.OrderByDescending(p => p.Id)
|
||||
};
|
||||
|
||||
return query.Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
return query.Skip(pq.Offset ?? 0).Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
}
|
||||
|
||||
public static IQueryable<T> Paginate<T>(
|
||||
|
@ -83,7 +83,7 @@ public static class QueryableExtensions
|
|||
_ => query.OrderByDescending(predicate)
|
||||
};
|
||||
|
||||
return query.Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
return query.Skip(pq.Offset ?? 0).Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
}
|
||||
|
||||
public static IQueryable<T> Paginate<T>(
|
||||
|
@ -137,7 +137,7 @@ public static class QueryableExtensions
|
|||
_ => query.OrderByDescending(predicate)
|
||||
};
|
||||
|
||||
return query.Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
return query.Skip(pq.Offset ?? 0).Take(Math.Min(pq.Limit ?? defaultLimit, maxLimit));
|
||||
}
|
||||
|
||||
public static IQueryable<T> Paginate<T>(
|
||||
|
|
Loading…
Add table
Reference in a new issue