diff --git a/src/components/variants/Calendar.tsx b/src/components/variants/Calendar.tsx index 2e5f6a6..b6b09dc 100644 --- a/src/components/variants/Calendar.tsx +++ b/src/components/variants/Calendar.tsx @@ -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 { + 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"))