1
Ride-Management
Jonathan Miller edited this page 2026-06-27 19:39:08 +00:00

Ride Management

Ride Types

Type Description
on_demand Immediate pickup, standard ride
scheduled Pre-booked ride with future pickup time
airport Airport transfer with flight tracking
corporate Corporate account ride with billing code

Ride Lifecycle

requested → dispatched → accepted → arriving → in_progress → completed
    │            │           │          │            │
    └→ cancelled └→ cancelled└→ cancelled└→ cancelled └→ cancelled
    │
    └→ no_driver → requested (retry)

State Transitions

From To Trigger
requested dispatched DispatchHelper::dispatchRide() finds a driver
requested no_driver No available drivers within radius
requested cancelled Rider cancels before dispatch
dispatched accepted Driver accepts the dispatch offer
dispatched cancelled Rider cancels or dispatch expires
accepted arriving Driver marks en route to pickup
accepted cancelled Either party cancels
arriving in_progress Driver starts the trip
arriving cancelled Rider no-show or cancellation
in_progress completed RideHelper::completeRide()
in_progress cancelled Emergency cancellation
no_driver requested System retries dispatch

Fare Estimation

When a ride is requested, FareHelper::calculateFare() provides an estimate based on:

  1. Estimated distance (straight-line or Google Maps distance matrix)
  2. Estimated duration
  3. Applicable fare rule (zone + vehicle type cascading)
  4. Current surge multiplier for the pickup zone
  5. Night surcharge if applicable
  6. Peak hour multiplier if within peak hours

The estimate is stored on the ride as estimated_fare. The final total_fare is calculated at completion using actual distance and duration.

Zone Detection

At ride request time, ZoneHelper::detectZone() identifies which zone the pickup and dropoff locations fall within, using haversine distance from zone center coordinates within the zone radius. Zone IDs and the current surge multiplier are stored on the ride record.