fix: improve GPS position sync reliability and add route trails (#21)
Backend: - Increase sync overlap buffer from 5s to 30s to catch late-arriving positions - Add position history endpoint GET /gps/locations/:driverId/history - Add logging for position sync counts (returned vs inserted) Frontend: - Add useDriverLocationHistory hook for fetching position trails - Draw Polyline route trails on GPS map for each tracked driver - Historical positions shown as semi-transparent paths behind live markers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,24 @@ export function useDriverLocation(driverId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get driver location history (for route trail display)
|
||||
*/
|
||||
export function useDriverLocationHistory(driverId: string | null, from?: string, to?: string) {
|
||||
return useQuery<Array<{ latitude: number; longitude: number; speed: number; timestamp: Date }>>({
|
||||
queryKey: ['gps', 'locations', driverId, 'history', from, to],
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams();
|
||||
if (from) params.append('from', from);
|
||||
if (to) params.append('to', to);
|
||||
const { data } = await api.get(`/gps/locations/${driverId}/history?${params}`);
|
||||
return data;
|
||||
},
|
||||
enabled: !!driverId,
|
||||
refetchInterval: 30000, // Refresh every 30 seconds
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get driver stats
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user