Update: 2026-06-10 18:11:50

This commit is contained in:
Hamza-Ayed
2026-06-10 18:11:50 +03:00
parent a0473a8b0f
commit 977adfe99d
27 changed files with 3946 additions and 206 deletions

View File

@@ -121,6 +121,8 @@ try {
c.color,
c.color_hex,
(SELECT ROUND(AVG(rating), 2) FROM ratingDriver WHERE driver_id = d.id) AS ratingDriver,
(SELECT COUNT(*) FROM ratingDriver WHERE driver_id = d.id) AS ratingCount,
(SELECT COUNT(*) FROM ride WHERE driver_id = d.id AND status IN ('Finished', 'finished')) AS completedRides,
dt.token
FROM driver d
LEFT JOIN CarRegistration c ON c.driverID = d.id
@@ -140,6 +142,16 @@ try {
}
$driverInfo['driverName'] = trim(($driverInfo['first_name'] ?? '') . ' ' . ($driverInfo['last_name'] ?? ''));
$driverInfo['ratingDriver'] = $driverInfo['ratingDriver'] ?: "5.0";
$ratingValue = (float) $driverInfo['ratingDriver'];
$ratingCount = (int) ($driverInfo['ratingCount'] ?? 0);
$completedRides = (int) ($driverInfo['completedRides'] ?? 0);
if ($ratingValue >= 4.8 && $ratingCount >= 50 && $completedRides >= 100) {
$driverInfo['driverTier'] = 'Professional driver';
} elseif ($ratingValue >= 4.5 && $ratingCount >= 15 && $completedRides >= 30) {
$driverInfo['driverTier'] = 'Trusted driver';
} else {
$driverInfo['driverTier'] = 'Verified driver';
}
}
// ═══════════════════════════════════════════════════════════
@@ -195,4 +207,4 @@ try {
} catch (PDOException $e) {
error_log("[accept_ride] CRITICAL: " . $e->getMessage());
printFailure("Server error");
}
}

View File

@@ -96,6 +96,17 @@ try {
FROM ratingDriver
WHERE ratingDriver.driver_id = :driverID_Sub
) AS ratingDriver,
(
SELECT COUNT(*)
FROM ratingDriver
WHERE ratingDriver.driver_id = :driverID_Sub
) AS ratingCount,
(
SELECT COUNT(*)
FROM ride
WHERE ride.driver_id = :driverID_Sub
AND ride.status IN ('Finished', 'finished')
) AS completedRides,
driverToken.token AS token
@@ -143,6 +154,16 @@ try {
$finalData[$field] = $encryptionHelper->decryptData($finalData[$field]);
}
}
$ratingValue = (float) ($finalData['ratingDriver'] ?: 5.0);
$ratingCount = (int) ($finalData['ratingCount'] ?? 0);
$completedRides = (int) ($finalData['completedRides'] ?? 0);
if ($ratingValue >= 4.8 && $ratingCount >= 50 && $completedRides >= 100) {
$finalData['driverTier'] = 'Professional driver';
} elseif ($ratingValue >= 4.5 && $ratingCount >= 15 && $completedRides >= 30) {
$finalData['driverTier'] = 'Trusted driver';
} else {
$finalData['driverTier'] = 'Verified driver';
}
}
echo json_encode([
@@ -155,4 +176,4 @@ try {
http_response_code(500);
echo json_encode(["status" => "failure", "message" => "Server Error: " . $e->getMessage()]);
}
?>
?>