Add debug counts
This commit is contained in:
@@ -74,17 +74,23 @@ try {
|
|||||||
$allPassengers = $stmtTarget->fetchAll(PDO::FETCH_ASSOC);
|
$allPassengers = $stmtTarget->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$targets = [];
|
$targets = [];
|
||||||
|
$debugCounts = ['JO' => 0, 'SY' => 0, 'EG' => 0, 'IQ' => 0, 'UNKNOWN' => 0, 'DECRYPT_FAIL' => 0];
|
||||||
foreach ($allPassengers as $p) {
|
foreach ($allPassengers as $p) {
|
||||||
$decryptedPhone = $encryptionHelper->decryptData($p['phone']);
|
$decryptedPhone = $encryptionHelper->decryptData($p['phone']);
|
||||||
if (!$decryptedPhone) continue;
|
if (!$decryptedPhone) {
|
||||||
|
$debugCounts['DECRYPT_FAIL']++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$cleanPhone = preg_replace('/[^0-9]/', '', $decryptedPhone);
|
$cleanPhone = preg_replace('/[^0-9]/', '', $decryptedPhone);
|
||||||
$pCountry = '';
|
$pCountry = 'UNKNOWN';
|
||||||
if (strpos($cleanPhone, '962') === 0 || strpos($cleanPhone, '07') === 0) $pCountry = 'JO';
|
if (strpos($cleanPhone, '962') === 0 || strpos($cleanPhone, '07') === 0) $pCountry = 'JO';
|
||||||
elseif (strpos($cleanPhone, '963') === 0 || (strpos($cleanPhone, '09') === 0 && strlen($cleanPhone) == 10)) $pCountry = 'SY';
|
elseif (strpos($cleanPhone, '963') === 0 || (strpos($cleanPhone, '09') === 0 && strlen($cleanPhone) == 10)) $pCountry = 'SY';
|
||||||
elseif (strpos($cleanPhone, '20') === 0 || (strpos($cleanPhone, '01') === 0 && strlen($cleanPhone) == 11)) $pCountry = 'EG';
|
elseif (strpos($cleanPhone, '20') === 0 || (strpos($cleanPhone, '01') === 0 && strlen($cleanPhone) == 11)) $pCountry = 'EG';
|
||||||
elseif (strpos($cleanPhone, '964') === 0) $pCountry = 'IQ';
|
elseif (strpos($cleanPhone, '964') === 0) $pCountry = 'IQ';
|
||||||
|
|
||||||
|
$debugCounts[$pCountry]++;
|
||||||
|
|
||||||
if ($pCountry === strtoupper($countryCode)) {
|
if ($pCountry === strtoupper($countryCode)) {
|
||||||
$targets[] = ['passenger_id' => $p['passenger_id'], 'decrypted_phone' => $decryptedPhone];
|
$targets[] = ['passenger_id' => $p['passenger_id'], 'decrypted_phone' => $decryptedPhone];
|
||||||
}
|
}
|
||||||
@@ -206,7 +212,13 @@ try {
|
|||||||
'whatsapp_sent_count' => $sentWhatsApp,
|
'whatsapp_sent_count' => $sentWhatsApp,
|
||||||
'sms_sent_count' => $sentSms
|
'sms_sent_count' => $sentSms
|
||||||
],
|
],
|
||||||
'total_dispatched' => count($dispatchedPassengers)
|
'total_dispatched' => count($dispatchedPassengers),
|
||||||
|
'debug_info' => [
|
||||||
|
'requested_country' => $countryCode,
|
||||||
|
'total_passengers_in_db' => count($allPassengers),
|
||||||
|
'matched_targets' => count($targets),
|
||||||
|
'distribution' => $debugCounts
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user