> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Braian551/viax/llms.txt
> Use this file to discover all available pages before exploring further.

# Driver Statistics

> View driver performance statistics and metrics

## Get Driver Statistics

```
GET /conductor/get_statistics.php
```

Retrieve comprehensive statistics for a driver including trips, ratings, and performance metrics.

### Query Parameters

<ParamField query="conductor_id" type="integer" required>
  Driver ID
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Request success status
</ResponseField>

<ResponseField name="statistics" type="object">
  Driver statistics and metrics

  <Expandable title="statistics structure">
    <ResponseField name="total_viajes" type="integer">
      Total number of completed trips
    </ResponseField>

    <ResponseField name="viajes_hoy" type="integer">
      Trips completed today
    </ResponseField>

    <ResponseField name="viajes_semana" type="integer">
      Trips completed this week
    </ResponseField>

    <ResponseField name="viajes_mes" type="integer">
      Trips completed this month
    </ResponseField>

    <ResponseField name="calificacion_promedio" type="number">
      Average rating (0-5)
    </ResponseField>

    <ResponseField name="total_calificaciones" type="integer">
      Number of ratings received
    </ResponseField>

    <ResponseField name="tasa_aceptacion" type="number">
      Trip acceptance rate (0-100%)
    </ResponseField>

    <ResponseField name="tasa_completacion" type="number">
      Trip completion rate (0-100%)
    </ResponseField>

    <ResponseField name="tasa_cancelacion" type="number">
      Trip cancellation rate (0-100%)
    </ResponseField>

    <ResponseField name="tiempo_promedio_respuesta" type="number">
      Average response time in seconds
    </ResponseField>

    <ResponseField name="distancia_total_km" type="number">
      Total distance driven in kilometers
    </ResponseField>

    <ResponseField name="horas_activo" type="number">
      Total hours active on platform
    </ResponseField>
  </Expandable>
</ResponseField>

### Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://76.13.114.194/conductor/get_statistics.php?conductor_id=25" \
    -H "Accept: application/json"
  ```

  ```dart Dart theme={null}
  Future<Map<String, dynamic>> getDriverStatistics(int conductorId) async {
    final response = await http.get(
      Uri.parse(
        'https://76.13.114.194/conductor/get_statistics.php?conductor_id=$conductorId',
      ),
      headers: {'Accept': 'application/json'},
    );
    
    if (response.statusCode == 200) {
      final data = jsonDecode(response.body);
      return data['statistics'];
    }
    throw Exception('Failed to load statistics');
  }
  ```

  ```javascript JavaScript theme={null}
  async function getDriverStatistics(conductorId) {
    const response = await fetch(
      `https://76.13.114.194/conductor/get_statistics.php?conductor_id=${conductorId}`,
      {
        headers: { 'Accept': 'application/json' },
      }
    );
    
    const data = await response.json();
    return data.statistics;
  }
  ```
</CodeGroup>

### Response Example

```json Success theme={null}
{
  "success": true,
  "statistics": {
    "total_viajes": 1247,
    "viajes_hoy": 8,
    "viajes_semana": 45,
    "viajes_mes": 142,
    "calificacion_promedio": 4.8,
    "total_calificaciones": 1180,
    "tasa_aceptacion": 92.5,
    "tasa_completacion": 98.2,
    "tasa_cancelacion": 1.8,
    "tiempo_promedio_respuesta": 45,
    "distancia_total_km": 8456.3,
    "horas_activo": 1245.5
  }
}
```

***

## Performance Metrics

### Acceptance Rate

Percentage of trip requests accepted by the driver:

```dart theme={null}
double calculateAcceptanceRate(
  int acceptedTrips,
  int totalRequests,
) {
  if (totalRequests == 0) return 0.0;
  return (acceptedTrips / totalRequests) * 100;
}
```

<Note>
  A high acceptance rate (above 90%) indicates good driver reliability.
</Note>

### Completion Rate

Percentage of accepted trips that were successfully completed:

```dart theme={null}
double calculateCompletionRate(
  int completedTrips,
  int acceptedTrips,
) {
  if (acceptedTrips == 0) return 0.0;
  return (completedTrips / acceptedTrips) * 100;
}
```

### Cancellation Rate

Percentage of trips cancelled by the driver:

```dart theme={null}
double calculateCancellationRate(
  int cancelledTrips,
  int totalTrips,
) {
  if (totalTrips == 0) return 0.0;
  return (cancelledTrips / totalTrips) * 100;
}
```

<Warning>
  High cancellation rates (above 10%) may result in penalties or account suspension.
</Warning>

***

## Rating System

Drivers are rated by passengers on a scale of 1-5 stars:

* **5 stars**: Excellent service
* **4 stars**: Good service
* **3 stars**: Acceptable service
* **2 stars**: Poor service
* **1 star**: Very poor service

### Rating Calculation

```dart theme={null}
double calculateAverageRating(
  List<int> ratings,
) {
  if (ratings.isEmpty) return 0.0;
  final sum = ratings.reduce((a, b) => a + b);
  return sum / ratings.length;
}

// Example:
final ratings = [5, 5, 4, 5, 4, 5, 5, 3, 5, 4];
final average = calculateAverageRating(ratings);
print(average); // 4.5
```

<Note>
  Drivers must maintain a minimum average rating (typically 4.0+) to remain active on the platform.
</Note>

***

## Performance Tiers

Drivers may be classified into performance tiers based on their statistics:

<CardGroup cols={3}>
  <Card title="Gold" icon="star" color="#FFD700">
    * Rating: 4.8+
    * Acceptance: 95%+
    * Completion: 98%+
  </Card>

  <Card title="Silver" icon="star-half" color="#C0C0C0">
    * Rating: 4.5+
    * Acceptance: 90%+
    * Completion: 95%+
  </Card>

  <Card title="Bronze" icon="circle" color="#CD7F32">
    * Rating: 4.0+
    * Acceptance: 85%+
    * Completion: 90%+
  </Card>
</CardGroup>

***

## Active Hours Tracking

Active hours are calculated when the driver is:

* Online and available for trips
* En route to pick up a passenger
* Transporting a passenger

```dart theme={null}
class ActiveHoursTracker {
  DateTime? sessionStart;
  double totalHours = 0.0;
  
  void startSession() {
    sessionStart = DateTime.now();
  }
  
  void endSession() {
    if (sessionStart != null) {
      final duration = DateTime.now().difference(sessionStart!);
      totalHours += duration.inMinutes / 60.0;
      sessionStart = null;
    }
  }
}
```

***

## Error Responses

<ResponseField name="404" type="Not Found">
  Driver not found
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error
</ResponseField>

## See Also

* [Driver Earnings](/api/drivers/earnings) - View earnings data
* [Trip History](/api/trips/history) - View completed trips
* [Driver Profile](/api/drivers/profile) - Manage driver profile
