Batch scheduled sync in 7-day chunks (API limit is 7 days)
Schedules endpoint has same 7-day limit as shifts. The 14-day forward window was being fetched in one call — split into two 7-day batches. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
793e97dbbb
commit
605feaab4e
1 changed files with 15 additions and 4 deletions
|
|
@ -196,10 +196,21 @@ export async function runRollingSync() {
|
||||||
current.setDate(current.getDate() + 7)
|
current.setDate(current.getDate() + 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scheduled: next 14 days (well within 31-day limit)
|
// Scheduled: next 14 days in 7-day batches
|
||||||
const fwdDate = new Date(today)
|
const schedEnd = new Date(today)
|
||||||
fwdDate.setDate(fwdDate.getDate() + 14)
|
schedEnd.setDate(schedEnd.getDate() + 14)
|
||||||
const scheduledRows = await syncScheduled(todayStr, fwdDate.toISOString().slice(0, 10))
|
let scheduledRows = 0
|
||||||
|
let schedCurrent = new Date(today)
|
||||||
|
while (schedCurrent <= schedEnd) {
|
||||||
|
const batchEnd = new Date(schedCurrent)
|
||||||
|
batchEnd.setDate(batchEnd.getDate() + 6)
|
||||||
|
if (batchEnd > schedEnd) batchEnd.setTime(schedEnd.getTime())
|
||||||
|
scheduledRows += await syncScheduled(
|
||||||
|
schedCurrent.toISOString().slice(0, 10),
|
||||||
|
batchEnd.toISOString().slice(0, 10)
|
||||||
|
)
|
||||||
|
schedCurrent.setDate(schedCurrent.getDate() + 7)
|
||||||
|
}
|
||||||
|
|
||||||
return { actualRows, scheduledRows }
|
return { actualRows, scheduledRows }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue