Rework workforce sync to per-date storage with rolling window
Replaces the single workforce_rota config snapshot (which was overwritten on each sync, losing data when switching weeks) with a workforce_daily_shifts table keyed by date. Sync now covers a rolling today-7 to today+28 window unconditionally — no date params needed. Each date's record carries a synced_at timestamp so the UI shows the age of the oldest date in view. Mid-week viewing works naturally since data is stored per date not per week. source column reserved for future timesheet replacement of past dates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1a8d8d9a2b
commit
c7066521ff
10 changed files with 278 additions and 178 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { BookingsData, StaffMember, GeneralTask, PickupData, TimeReqs, WorkforceRota, Adjustment } from './types'
|
||||
import type { BookingsData, StaffMember, GeneralTask, PickupData, TimeReqs, WfDayData, Adjustment } from './types'
|
||||
|
||||
const BASE = '/hk-planner/api'
|
||||
|
||||
|
|
@ -8,7 +8,6 @@ export interface ConfigData {
|
|||
pickup_data: PickupData
|
||||
general_tasks: GeneralTask[]
|
||||
last_reviewed: string
|
||||
workforce_rota: WorkforceRota | null
|
||||
workforce_departments: string[]
|
||||
adjustments: Adjustment[]
|
||||
warn_over_red_hrs: number
|
||||
|
|
@ -117,8 +116,12 @@ export function putWorkforceDepartments(dept_ids: string[]): Promise<{ ok: boole
|
|||
})
|
||||
}
|
||||
|
||||
export function syncWorkforceRota(start: string, end: string): Promise<WorkforceRota> {
|
||||
return request(`/workforce/sync?start=${start}&end=${end}`, { method: 'POST' })
|
||||
export function syncWorkforce(): Promise<{ ok: boolean; from: string; to: string; dates_synced: number }> {
|
||||
return request('/workforce/sync', { method: 'POST' })
|
||||
}
|
||||
|
||||
export function getWorkforceShifts(start: string, end: string): Promise<Record<string, WfDayData>> {
|
||||
return request(`/workforce/shifts?start=${start}&end=${end}`)
|
||||
}
|
||||
|
||||
export function getWorkforceStaff(): Promise<{ id: string; name: string }[]> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue