Real time job tracking for shift work
Job acceptance under contention, location that is only collected when it means something, and payment at the end. From TOVOZO.
TOVOZO connects hotels that need shift staff with the people who work those shifts. I built the real time tracking, the notification system and the location handling.
Two audiences, opposite anxieties. The manager needs to know the shift will be covered. The worker needs to know the job is real and that they will be paid.
Job acceptance is a race, so settle it on the server
A job posts. Push goes to every eligible worker at once. Several tap accept within the same second.
Resolving that on the client, or by reading then writing, produces a job accepted twice and two people showing up.
update jobs
set status = 'accepted',
worker_id = $worker,
accepted_at = now()
where id = $job
and status = 'open'
returning id;Zero rows returned means somebody else got there first. The losing worker gets a clear message immediately, which matters: a job that silently vanishes from a list feels like a bug, and workers who think the app is buggy stop opening it.
Location, collected in a window
Continuous location tracking would be a battery problem, a privacy problem and an answer to a question nobody asked.
What the manager actually wants to know is narrow: is this person on their way, and are they here. So location is collected in a window that opens some time before the shift and closes when it ends. Outside that window it is not collected, and the app says so plainly.
Inside the window, updates are distance filtered rather than time filtered. A worker standing still generates no writes. Time based polling generates hundreds of identical rows and a flat battery.
Notifications carry the state changes
Push through Firebase Cloud Messaging and APNs for the events that change someone's plan: a job offered, accepted, cancelled, a shift starting, a payment released.
The rule I applied: a notification is warranted when it changes what the recipient should do next. Everything else belongs in the app, not on a lock screen. Staffing products are easy to make noisy, and a noisy one gets its notifications turned off, which removes the channel you actually need for cancellations.
Payment at the end
Stripe handles the money once a shift is confirmed complete. The design point worth stating is that shift completion and payment release are separate states with an explicit transition between them, not one event.
Collapsing them means any dispute about whether a shift was completed becomes a dispute about a payment that has already moved.
Trade-offs
Server side acceptance adds a round trip before a worker sees confirmation. That is the correct place to spend it.
A location window means a gap where the manager cannot see the worker. That gap is the feature, not a limitation.
Distance filtered updates mean the last known position can be stale if someone stops moving. For this product, a stale position for a stationary worker is fine.
What I would add
Predicted arrival based on the trace already collected, so the manager gets an answer instead of a map they have to interpret. The data is there. It is a product decision, not a technical one.