diff --git a/backend/routes/analysis.py b/backend/routes/analysis.py index c92c8b0..5f0bf54 100644 --- a/backend/routes/analysis.py +++ b/backend/routes/analysis.py @@ -373,10 +373,19 @@ async def analyze_user_agents(ip: str): AND time >= now() - INTERVAL 24 HOUR GROUP BY ua ORDER BY count DESC - LIMIT 10 + LIMIT 500 + """ + + # Total réel des requêtes (pour les pourcentages corrects) + ip_total_query = """ + SELECT count() + FROM mabase_prod.http_logs + WHERE src_ip = %(ip)s + AND time >= now() - INTERVAL 24 HOUR """ ip_ua_result = db.query(ip_ua_query, {"ip": ip}) + ip_total_result = db.query(ip_total_query, {"ip": ip}) # Classification des UAs def classify_ua(ua: str) -> str: @@ -389,8 +398,10 @@ async def analyze_user_agents(ip: str): return 'script' return 'normal' - # Calculer le total - total_count = sum(row[1] for row in ip_ua_result.result_rows) + # Total réel de toutes les requêtes (pour des pourcentages corrects même avec LIMIT) + total_count = ip_total_result.result_rows[0][0] if ip_total_result.result_rows else 0 + if total_count == 0: + total_count = sum(row[1] for row in ip_ua_result.result_rows) ip_user_agents = [ UserAgentData( diff --git a/frontend/src/components/analysis/CountryAnalysis.tsx b/frontend/src/components/analysis/CountryAnalysis.tsx index 448e9d9..83ed7b7 100644 --- a/frontend/src/components/analysis/CountryAnalysis.tsx +++ b/frontend/src/components/analysis/CountryAnalysis.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { InfoTip } from '../ui/Tooltip'; interface CountryData { code: string; @@ -84,6 +85,15 @@ export function CountryAnalysis({ ip, asn }: CountryAnalysisProps) {