Workforce scheduling platform
Ongoing backend work on a staffing and scheduling platform — most recently the Google Calendar sync for personnel assignments and a responsive retrofit of a legacy WebForms app.
- 01Shift exists?and a staff member is assigned
- 02Connected?Google configured, user has linked a calendar
- 03In window?tomorrow onward — same-day and past shifts skipped
- 04Status?valid shift status for syncing
- 05Actcreate, update or delete the event
The problem
Staffpoint is a workforce-management system for staffing agencies. Staff wanted their shifts on their own Google Calendar — created when they are assigned, updated when anything changes, removed when a shift is cancelled.
What I built
The entire sync state is one nullable googleCalendarEventId column on the shift. A single method, SyncGoogleCalendarForShift, applies five rules in order (shown above) and is called from every place that changes an assignment: assigning, editing times, confirming and cancelling.
- OAuth tokens are stored as JSON on the staff record.
- Each event carries the shift ID as a private extended property, so any calendar event can be traced back to its shift.
- Sync runs inside the web request, wrapped so a Google failure never fails the user’s action.
What broke, and the fix
- Expired tokens failed silently at first. Tokens now record
IssuedUtc, refresh automatically, andinvalid_grantis detected so the user can reconnect. - Orphan events. Clearing the event ID before deleting the event made cleanup impossible. IDs are now captured before the mutation, the database updated, then removals processed.
- Reconnect backfill. A newly connected user gets every Assigned or Completed shift from tomorrow onward.
What I’d do next
Move sync to an async queue — synchronous execution is the main limitation — and encrypt stored tokens.