This commit is contained in:
Lizandro Guarnizo
2026-01-22 11:29:24 -05:00
parent 84e2d1d236
commit fcba5919a8
5 changed files with 31 additions and 7 deletions
+8 -1
View File
@@ -40,12 +40,19 @@ try {
// Total de mensajes
$totalconversations = $db->fetch("SELECT COUNT(*) as count FROM conversations")['count'];
// Mensajes pendientes / no leídos: preferir columna is_read si existe, si no usar status = 'received'
$unreadResult = $db->fetch(
"SELECT COUNT(*) as count FROM conversations WHERE direction = 'incoming' AND ( (is_read IS NULL OR is_read = 0) OR status = 'received' )"
);
$unreadMessages = intval($unreadResult['count'] ?? 0);
$stats = [
'total_users' => (int)$totalUsers,
'conversations_today' => (int)$conversationsToday,
'active_users' => (int)$activeUsers,
'total_conversations' => (int)$totalconversations
'total_conversations' => (int)$totalconversations,
'unread_messages' => $unreadMessages
];
echo json_encode($stats);