modif erreur chatbot
This commit is contained in:
@ -31,16 +31,17 @@ foreach ($all_models as $model) {
|
||||
$models_by_provider[$model['provider']][] = $model;
|
||||
}
|
||||
|
||||
// Récupérer les statistiques d'utilisation
|
||||
// Récupérer les statistiques d'utilisation (requête directe)
|
||||
$stats = $db->fetchOne(
|
||||
"SELECT
|
||||
COUNT(DISTINCT id) as total_conversations,
|
||||
SUM(total_messages) as total_messages,
|
||||
provider,
|
||||
model_used
|
||||
FROM v_chatbot_usage_stats
|
||||
WHERE id_enseignant = ?
|
||||
GROUP BY provider, model_used
|
||||
COUNT(DISTINCT cc.id) as total_conversations,
|
||||
COUNT(cm.id) as total_messages,
|
||||
cc.provider,
|
||||
cc.model_used
|
||||
FROM chat_conversations cc
|
||||
LEFT JOIN chat_messages cm ON cm.id_conversation = cc.id
|
||||
WHERE cc.id_enseignant = ?
|
||||
GROUP BY cc.provider, cc.model_used
|
||||
ORDER BY total_conversations DESC
|
||||
LIMIT 1",
|
||||
[$user['id_utilisateur']]
|
||||
@ -48,14 +49,15 @@ $stats = $db->fetchOne(
|
||||
|
||||
$stats_detail = $db->fetchAll(
|
||||
"SELECT
|
||||
provider,
|
||||
model_used,
|
||||
SUM(total_conversations) as conversations,
|
||||
SUM(total_messages) as messages,
|
||||
month
|
||||
FROM v_chatbot_usage_stats
|
||||
WHERE id_enseignant = ?
|
||||
GROUP BY provider, model_used, month
|
||||
cc.provider,
|
||||
cc.model_used,
|
||||
COUNT(DISTINCT cc.id) as conversations,
|
||||
COUNT(cm.id) as messages,
|
||||
DATE_FORMAT(cc.date_debut, '%Y-%m') as month
|
||||
FROM chat_conversations cc
|
||||
LEFT JOIN chat_messages cm ON cm.id_conversation = cc.id
|
||||
WHERE cc.id_enseignant = ?
|
||||
GROUP BY cc.provider, cc.model_used, month
|
||||
ORDER BY month DESC, conversations DESC",
|
||||
[$user['id_utilisateur']]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user