fix(calendar): paginate test_drives lookup (200-row server cap dropped XUV3XO)
This commit is contained in:
parent
5ef5343982
commit
b621eb9d5d
@ -89,13 +89,32 @@ export function CalendarView() {
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
|
||||
// The /rdbms-templates/.../records handler clamps limit to 200 server-side,
|
||||
// so loop with offset until we've drained `total`. Without this, ~80 of 280
|
||||
// test_drives are silently dropped and entire cars (heap-order-last) vanish.
|
||||
const PAGE = 200;
|
||||
async function fetchAllDrives(): Promise<TestDrive[]> {
|
||||
const out: TestDrive[] = [];
|
||||
let offset = 0;
|
||||
for (;;) {
|
||||
const resp = await fetchRdbmsLookupRecords(CALENDAR_LOOKUPS.TEST_DRIVES.rdbmsTemplateUuid, {
|
||||
workflowId: WORKFLOW_NUMERIC_ID,
|
||||
activityId: ACTIVITY_IDS.INIT_ACTIVITY,
|
||||
fieldId: CALENDAR_LOOKUPS.TEST_DRIVES.fieldId,
|
||||
limit: PAGE,
|
||||
offset,
|
||||
});
|
||||
const batch = (resp.records as unknown as TestDrive[]) ?? [];
|
||||
out.push(...batch);
|
||||
if (batch.length < PAGE || out.length >= resp.total) break;
|
||||
offset += PAGE;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
fetchRdbmsLookupRecords(CALENDAR_LOOKUPS.TEST_DRIVES.rdbmsTemplateUuid, {
|
||||
workflowId: WORKFLOW_NUMERIC_ID,
|
||||
activityId: ACTIVITY_IDS.INIT_ACTIVITY,
|
||||
fieldId: CALENDAR_LOOKUPS.TEST_DRIVES.fieldId,
|
||||
limit: 1000,
|
||||
}),
|
||||
fetchAllDrives(),
|
||||
fetchRdbmsLookupRecords(CALENDAR_LOOKUPS.CARS.rdbmsTemplateUuid, {
|
||||
workflowId: WORKFLOW_NUMERIC_ID,
|
||||
activityId: ACTIVITY_IDS.INIT_ACTIVITY,
|
||||
@ -105,11 +124,9 @@ export function CalendarView() {
|
||||
])
|
||||
.then(([td, c]) => {
|
||||
if (cancelled) return;
|
||||
setDrives((td.records as unknown as TestDrive[]) ?? []);
|
||||
setDrives(td);
|
||||
setCars((c.records as unknown as Car[]) ?? []);
|
||||
const days = (td.records as unknown as TestDrive[])
|
||||
.map((r) => istDayKey(r.slot_start))
|
||||
.sort();
|
||||
const days = td.map((r) => istDayKey(r.slot_start)).sort();
|
||||
setWeekStart(days[0] ?? null);
|
||||
})
|
||||
.catch((e: any) => !cancelled && setError(e?.message ?? "Failed to load"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user