fix(dashboard): fix chart crash, field name mismatches, and demo data injection
- overview.js: fix time-series chart crash (data is {series:[...]}, not array; field is 'time' not 'hour')
- monitoring.js: use fallback field names (total_tokens/tokens, duration_ms/duration) for WebSocket vs API compat
- monitoring.js: disable localhost demo data injection that mixed fake data with real
- websocket.js: fix duplicate condition and field name mismatches in dead-code handlers
- logging/mod.rs: add info! logs for successful DB insert and broadcast count for diagnostics
This commit is contained in:
@@ -2,7 +2,7 @@ use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
use tokio::sync::broadcast;
|
||||
use tracing::warn;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::errors::AppError;
|
||||
|
||||
@@ -42,14 +42,19 @@ impl RequestLogger {
|
||||
// Spawn async task to log without blocking response
|
||||
tokio::spawn(async move {
|
||||
// Broadcast to dashboard
|
||||
let _ = tx.send(serde_json::json!({
|
||||
let broadcast_result = tx.send(serde_json::json!({
|
||||
"type": "request",
|
||||
"channel": "requests",
|
||||
"payload": log
|
||||
}));
|
||||
match broadcast_result {
|
||||
Ok(receivers) => info!("Broadcast request log to {} dashboard listeners", receivers),
|
||||
Err(_) => {} // No active WebSocket clients — expected when dashboard isn't open
|
||||
}
|
||||
|
||||
if let Err(e) = Self::insert_log(&pool, log).await {
|
||||
warn!("Failed to log request to database: {}", e);
|
||||
match Self::insert_log(&pool, log).await {
|
||||
Ok(()) => info!("Request logged to database successfully"),
|
||||
Err(e) => warn!("Failed to log request to database: {}", e),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user