```php
<?php

require_once '../../core/api_bootstrap.php';
require_once '../../core/employee_auth.php';
EmployeeAuth::check('view_analytics');
try {

$db = new Database();
$conn = $db->connect();

$query = "

SELECT
COALESCE(ci.name,'Unknown') AS city,
COUNT(l.id) AS total_leads

FROM customer_leads l

LEFT JOIN pincodes p
ON p.pincode = l.pincode COLLATE utf8mb4_unicode_ci

LEFT JOIN cities ci
ON ci.id = p.city_id

GROUP BY city

ORDER BY total_leads DESC

";

$stmt = $conn->prepare($query);
$stmt->execute();

$data = $stmt->fetchAll(PDO::FETCH_ASSOC);

Response::success($data);

}
catch(Exception $e){

Logger::log('system.log',$e->getMessage());
Response::error('Server error',500);

}