Update: 2026-07-22 01:07:41

This commit is contained in:
Hamza-Ayed
2026-07-22 01:07:41 +03:00
parent 11d7d86b2f
commit 26d0ec2982
+38 -20
View File
@@ -205,21 +205,9 @@ async function simulateTrip(tripIndex) {
); );
console.log(`[Trip ${tripIndex}] Accepted ride #${rideId}. (API: ${Date.now() - acceptStart}ms)`); console.log(`[Trip ${tripIndex}] Accepted ride #${rideId}. (API: ${Date.now() - acceptStart}ms)`);
// 4. Simulate Driving (Updates Location) // 4. Start Ride API Call
let steps = 0;
const driveInterval = setInterval(async () => {
steps++;
socket.emit('update_location', {
lat: 31.95 + (steps * 0.001),
lng: 35.91 + (steps * 0.001),
heading: 90,
speed: 40,
status: 'on'
});
if (steps === 3) {
try { try {
const startFormData = new URLSearchParams({ id: String(rideId), driver_id: String(driverId), status: 'start' }); const startFormData = new URLSearchParams({ id: String(rideId), driver_id: String(driverId), status: 'Begin' });
await axios.post( await axios.post(
`${argv.baseUrl}/ride/rides/start_ride.php`, `${argv.baseUrl}/ride/rides/start_ride.php`,
startFormData.toString(), startFormData.toString(),
@@ -232,16 +220,46 @@ async function simulateTrip(tripIndex) {
timeout: 10000 timeout: 10000
} }
); );
console.log(`[Trip ${tripIndex}] Started ride #${rideId}`); console.log(`[Trip ${tripIndex}] 🚗 Started ride #${rideId}`);
} catch (e) { } catch (e) {
debug(`start_ride error: ${e.message}`); debug(`start_ride error: ${e.message}`);
} }
}
if (steps === 6) { // 5. Simulate Driving (4 Random GPS Location Updates)
let currentLat = 31.95;
let currentLng = 35.91;
let steps = 0;
const driveInterval = setInterval(async () => {
steps++;
currentLat += 0.0005 + (Math.random() * 0.0005);
currentLng += 0.0005 + (Math.random() * 0.0005);
socket.emit('update_location', {
lat: currentLat,
lng: currentLng,
heading: Math.floor(Math.random() * 360),
speed: 40 + Math.floor(Math.random() * 20),
status: 'on'
});
console.log(`[Trip ${tripIndex}] 📍 Driver GPS update #${steps}: (${currentLat.toFixed(4)}, ${currentLng.toFixed(4)})`);
if (steps >= 4) {
clearInterval(driveInterval); clearInterval(driveInterval);
// 6. Finish Ride API Call
try { try {
const finishFormData = new URLSearchParams({ id: String(rideId), driver_id: String(driverId), status: 'finish' }); const finishFormData = new URLSearchParams({
rideId: String(rideId),
driver_id: String(driverId),
passengerId: String(passengerId),
status: 'Finished',
actualDistance: '2.5',
actualDuration: '10',
country_code: 'Jordan'
});
await axios.post( await axios.post(
`${argv.baseUrl}/ride/rides/finish_ride_updates.php`, `${argv.baseUrl}/ride/rides/finish_ride_updates.php`,
finishFormData.toString(), finishFormData.toString(),
@@ -254,7 +272,7 @@ async function simulateTrip(tripIndex) {
timeout: 10000 timeout: 10000
} }
); );
console.log(`[Trip ${tripIndex}] ✅ Finished ride #${rideId}.`); console.log(`[Trip ${tripIndex}] 🏁 Finished ride #${rideId} successfully.`);
} catch (e) { } catch (e) {
debug(`finish_ride error: ${e.message}`); debug(`finish_ride error: ${e.message}`);
} }
@@ -262,7 +280,7 @@ async function simulateTrip(tripIndex) {
metrics.successful++; metrics.successful++;
finish(true); finish(true);
} }
}, 1000); }, 500);
} catch (err) { } catch (err) {
console.error(`[Trip ${tripIndex}] ❌ API Error (acceptRide): ${err.message}`); console.error(`[Trip ${tripIndex}] ❌ API Error (acceptRide): ${err.message}`);