Vapora/crates/vapora-backend/src/services/kg_analytics_service.rs
Jesús Pérez dd68d190ef ci: Update pre-commit hooks configuration
- Exclude problematic markdown files from linting (existing legacy issues)
- Make clippy check less aggressive (warnings only, not -D warnings)
- Move cargo test to manual stage (too slow for pre-commit)
- Exclude SVG files from end-of-file-fixer and trailing-whitespace
- Add markdown linting exclusions for existing documentation

This allows pre-commit hooks to run successfully on new code without
blocking commits due to existing issues in legacy documentation files.
2026-01-11 21:32:56 +00:00

71 lines
2.0 KiB
Rust

// KG Analytics Service - Analytics query interface
// Phase 6: REST API analytics endpoints
use std::sync::Arc;
use surrealdb::engine::remote::ws::Client;
use surrealdb::Surreal;
use tracing::debug;
use vapora_knowledge_graph::{
analytics::{AgentPerformance, CostEfficiencyReport, DashboardMetrics, TaskTypeAnalytics},
KGPersistence, TimePeriod,
};
/// KG Analytics service for querying execution analytics
#[derive(Clone)]
pub struct KGAnalyticsService {
persistence: Arc<KGPersistence>,
}
impl KGAnalyticsService {
/// Create new KG Analytics service
pub fn new(db: Surreal<Client>) -> Self {
let persistence = Arc::new(KGPersistence::new(db));
Self { persistence }
}
/// Get agent performance for given period
pub async fn get_agent_performance(
&self,
agent_id: &str,
period: TimePeriod,
) -> anyhow::Result<AgentPerformance> {
debug!(
"Querying agent performance for {} in {:?}",
agent_id, period
);
self.persistence
.get_agent_performance(agent_id, period)
.await
}
/// Get task type analytics
pub async fn get_task_type_analytics(
&self,
task_type: &str,
period: TimePeriod,
) -> anyhow::Result<TaskTypeAnalytics> {
debug!("Querying task type analytics for {}", task_type);
self.persistence
.get_task_type_analytics(task_type, period)
.await
}
/// Get system dashboard metrics
pub async fn get_dashboard_metrics(
&self,
period: TimePeriod,
) -> anyhow::Result<DashboardMetrics> {
debug!("Querying dashboard metrics for {:?}", period);
self.persistence.get_dashboard_metrics(period).await
}
/// Get cost efficiency report
pub async fn get_cost_report(
&self,
period: TimePeriod,
) -> anyhow::Result<CostEfficiencyReport> {
debug!("Querying cost report for {:?}", period);
self.persistence.get_cost_report(period).await
}
}