<?php
require_once __DIR__ . '/../../connect.php';

// لا حاجة للمتغير id لأنه غير مستخدم فعليًا
// $id = filterRequest("id");

$sql = "
    SELECT
        (
            SELECT COUNT(*) 
            FROM `ride` 
            WHERE `status` = 'Finished' 
            AND `created_at` BETWEEN CURRENT_DATE() + INTERVAL 7 HOUR AND CURRENT_DATE() + INTERVAL 10 HOUR
        ) AS morning_count,
        (
            SELECT COUNT(*) 
            FROM `ride` 
            WHERE `status` = 'Finished' 
            AND `created_at` BETWEEN CURRENT_DATE() + INTERVAL 15 HOUR AND CURRENT_DATE() + INTERVAL 18 HOUR
        ) AS afternoon_count
";

$stmt = $con->prepare($sql);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);

echo json_encode([
    "status" => "success",
    "data" => $row
]);
?>