Scope manual sync buttons to current view dates only

Sync rota and pull timesheets now operate on the 7-day view window rather
than rolling default windows — reduces API calls and allows backdating.
Cron job still uses rolling defaults via runRotaSync()/runTimesheetSync().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-22 20:08:43 +00:00
parent 9bfd14a082
commit ffefa1914f
9 changed files with 81 additions and 60 deletions

View file

@ -298,13 +298,14 @@ export function Planner() {
// ── Workforce sync ───────────────────────────────────────────────────────────
async function syncRota() {
if (!bookings) return
const start = bookings.dates[0]
const end = bookings.dates[bookings.dates.length - 1]
setSyncing(true)
try {
await syncWorkforce()
if (bookings) {
const shifts = await getWorkforceShifts(bookings.dates[0], bookings.dates[bookings.dates.length - 1])
setWfShifts(shifts)
}
await syncWorkforce(start, end)
const shifts = await getWorkforceShifts(start, end)
setWfShifts(shifts)
flash('Rota synced from Workforce')
} catch (e) {
flash(e instanceof Error ? e.message : 'Sync failed', true)
@ -314,13 +315,14 @@ export function Planner() {
}
async function syncTimesheetData() {
if (!bookings) return
const start = bookings.dates[0]
const end = bookings.dates[bookings.dates.length - 1]
setTimesheetSyncing(true)
try {
await syncTimesheets()
if (bookings) {
const shifts = await getWorkforceShifts(bookings.dates[0], bookings.dates[bookings.dates.length - 1])
setWfShifts(shifts)
}
await syncTimesheets(start, end)
const shifts = await getWorkforceShifts(start, end)
setWfShifts(shifts)
flash('Timesheets pulled from Workforce')
} catch (e) {
flash(e instanceof Error ? e.message : 'Timesheet sync failed', true)