Get System Statistics
GET /admin/dashboard_stats.php
Retrieve comprehensive platform statistics for the admin dashboard.
Query Parameters
Response
System-wide statistics Total registered users (all types)
Active drivers currently online
Total trips completed (all time)
Platform revenue today (COP)
Total platform revenue (COP)
New user registrations today
New user registrations this week
Request Example
curl -X GET "https://76.13.114.194/admin/dashboard_stats.php?admin_id=1" \
-H "Accept: application/json"
Response Example
{
"success" : true ,
"stats" : {
"total_usuarios" : 2547 ,
"total_conductores" : 342 ,
"conductores_activos" : 125 ,
"conductores_pendientes" : 18 ,
"viajes_hoy" : 487 ,
"viajes_total" : 45623 ,
"viajes_activos" : 23 ,
"ganancia_hoy" : 9740000 ,
"ganancia_total" : 912800000 ,
"usuarios_nuevos_hoy" : 15 ,
"usuarios_nuevos_semana" : 84
}
}
Dashboard Metrics
User Growth Track new user registrations over time
Trip Volume Monitor daily and total trip counts
Revenue Track platform earnings and commissions
Driver Availability Monitor active drivers and approval queue
Calculate Metrics
class AdminAnalytics {
final Map < String , dynamic > stats;
AdminAnalytics ( this .stats);
// Driver approval rate
double get driverApprovalRate {
final total = stats[ 'total_conductores' ] as int ;
final pending = stats[ 'conductores_pendientes' ] as int ;
if (total == 0 ) return 0.0 ;
return ((total - pending) / total) * 100 ;
}
// Average trips per driver today
double get avgTripsPerDriverToday {
final trips = stats[ 'viajes_hoy' ] as int ;
final drivers = stats[ 'conductores_activos' ] as int ;
if (drivers == 0 ) return 0.0 ;
return trips / drivers;
}
// Average revenue per trip today
double get avgRevenuePerTripToday {
final revenue = stats[ 'ganancia_hoy' ] as num ;
final trips = stats[ 'viajes_hoy' ] as int ;
if (trips == 0 ) return 0.0 ;
return revenue / trips;
}
// Driver utilization rate
double get driverUtilizationRate {
final active = stats[ 'conductores_activos' ] as int ;
final total = stats[ 'total_conductores' ] as int ;
if (total == 0 ) return 0.0 ;
return (active / total) * 100 ;
}
}
Revenue Analytics
Calculate platform earnings from trip commissions:
class RevenueCalculator {
static const double platformCommissionRate = 0.15 ; // 15%
double calculatePlatformRevenue ( double tripPrice) {
return tripPrice * platformCommissionRate;
}
double calculateDriverEarnings ( double tripPrice) {
return tripPrice * ( 1 - platformCommissionRate);
}
}
Revenue Breakdown
class RevenueBreakdown {
final double totalRevenue;
final double platformCommission;
final double driverPayouts;
final int tripCount;
RevenueBreakdown ({
required this .totalRevenue,
required this .platformCommission,
required this .driverPayouts,
required this .tripCount,
});
double get avgTripValue => tripCount > 0 ? totalRevenue / tripCount : 0.0 ;
double get avgCommissionPerTrip => tripCount > 0 ? platformCommission / tripCount : 0.0 ;
}
User Analytics
User Growth Tracking
class UserGrowthMetrics {
int calculateGrowthRate ( int newUsers, int totalUsers) {
if (totalUsers == 0 ) return 0 ;
return ((newUsers / totalUsers) * 100 ). round ();
}
double calculateRetentionRate (
int activeUsersThisWeek,
int activeUsersLastWeek,
) {
if (activeUsersLastWeek == 0 ) return 0.0 ;
return (activeUsersThisWeek / activeUsersLastWeek) * 100 ;
}
}
Trip Analytics
Trip Status Distribution
class TripAnalytics {
Map < String , int > getTripStatusDistribution ( List < Trip > trips) {
final distribution = < String , int > {};
for ( final trip in trips) {
distribution[trip.estado] = (distribution[trip.estado] ?? 0 ) + 1 ;
}
return distribution;
}
double calculateCompletionRate ( List < Trip > trips) {
if (trips.isEmpty) return 0.0 ;
final completed = trips. where ((t) => t.estado == 'completado' ).length;
return (completed / trips.length) * 100 ;
}
double calculateCancellationRate ( List < Trip > trips) {
if (trips.isEmpty) return 0.0 ;
final cancelled = trips. where ((t) => t.estado == 'cancelado' ).length;
return (cancelled / trips.length) * 100 ;
}
}
Time Series Data
For historical trend analysis, consider implementing dedicated analytics endpoints that return time-series data for charting and visualization.
Example Time Series Query
Future < List < Map < String , dynamic >>> getTripsOverTime (
DateTime startDate,
DateTime endDate,
String interval, // 'day', 'week', 'month'
) async {
// Implementation would query database for trip counts
// grouped by the specified time interval
return [];
}
Export Data
For data export functionality, implement endpoints that generate CSV or Excel files with filtered data ranges.
Error Responses
Insufficient admin privileges
Server error retrieving statistics
See Also