perf(admin): paginate responses on the server
This commit is contained in:
@@ -96,6 +96,8 @@ export async function getFilteredSubmissions(
|
||||
.from(submissions)
|
||||
.where(where);
|
||||
|
||||
const pageCount = Math.max(1, Math.ceil(total / RESULTS_PAGE_SIZE));
|
||||
const page = Math.min(filters.page, pageCount);
|
||||
const baseQuery = db
|
||||
.select()
|
||||
.from(submissions)
|
||||
@@ -106,9 +108,9 @@ export async function getFilteredSubmissions(
|
||||
? await baseQuery
|
||||
: await baseQuery
|
||||
.limit(RESULTS_PAGE_SIZE)
|
||||
.offset((filters.page - 1) * RESULTS_PAGE_SIZE);
|
||||
.offset((page - 1) * RESULTS_PAGE_SIZE);
|
||||
|
||||
return { rows, total };
|
||||
return { rows, total, page, pageCount };
|
||||
}
|
||||
|
||||
export function resultFiltersToSearchParams(
|
||||
|
||||
Reference in New Issue
Block a user