Apply fetching pages in batches suggestion from @greptile-apps[bot]

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Ceder Dens 2026-06-05 20:16:12 +02:00 • committed by GitHub
parent ed3fe65c77
commit 7ee4833764
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -133,11 +133,17 @@ export function LogDetailsDrawer({
const pagesToFetch = Math.min(firstPage.total_pages ?? 1, MAX_SESSION_PAGES);
if (pagesToFetch > 1) {
const remaining = await Promise.all(
Array.from({ length: pagesToFetch - 1 }, (_, i) =>
sessionSpendLogsCall(accessToken, sessionId, i + 2, SESSION_PAGE_SIZE),
),
);
const BATCH = 5;
const remaining: Awaited<ReturnType<typeof sessionSpendLogsCall>>[] = [];
for (let start = 2; start <= pagesToFetch; start += BATCH) {
const end = Math.min(start + BATCH - 1, pagesToFetch);
const batch = await Promise.all(
Array.from({ length: end - start + 1 }, (_, i) =>
sessionSpendLogsCall(accessToken, sessionId, start + i, SESSION_PAGE_SIZE),
),
);
remaining.push(...batch);
}
for (const page of remaining) {
rows = rows.concat(page.data || []);
}