perf(admin): paginate responses on the server

This commit is contained in:
2026-08-09 21:58:19 +07:00 Unverified
parent 916aaf92ef
commit 78373b76cc
3 changed files with 183 additions and 175 deletions
+4 -2
View File
@@ -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(