Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 1x 11x 11x 11x 11x 6x 6x 4x 4x 4x 4x 3x 3x 3x 3x 3x 3x 2x 2x 3x 3x 3x 3x 3x 3x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Analytics API Service
*
* Handles analytics and metrics operations:
* - Historical metrics
* - Prediction trends
* - Performance analytics
*/
import api from '@/lib/api';
/**
* Time series data point
*/
export interface TimeSeriesPoint {
timestamp: string;
value: number;
}
/**
* Prediction metrics over time
*/
export interface PredictionMetrics {
total_predictions: TimeSeriesPoint[];
successful_predictions: TimeSeriesPoint[];
failed_predictions: TimeSeriesPoint[];
average_confidence: TimeSeriesPoint[];
average_uncertainty: TimeSeriesPoint[];
}
/**
* WebSDR performance metrics
*/
export interface WebSDRPerformance {
websdr_id: number;
name: string;
uptime_percentage: number;
average_snr: number;
total_acquisitions: number;
successful_acquisitions: number;
}
/**
* System performance metrics
*/
export interface SystemPerformance {
cpu_usage: TimeSeriesPoint[];
memory_usage: TimeSeriesPoint[];
api_response_times: TimeSeriesPoint[];
active_tasks: TimeSeriesPoint[];
}
/**
* Get prediction metrics for the specified time range
*/
export async function getPredictionMetrics(timeRange: string = '7d'): Promise<PredictionMetrics> {
const response = await api.get<PredictionMetrics>('/api/v1/analytics/predictions/metrics', {
params: { time_range: timeRange }
});
return response.data;
}
/**
* Get WebSDR performance metrics
*/
export async function getWebSDRPerformance(timeRange: string = '7d'): Promise<WebSDRPerformance[]> {
const response = await api.get<WebSDRPerformance[]>('/api/v1/analytics/websdr/performance', {
params: { time_range: timeRange }
});
return response.data;
}
/**
* Get system performance metrics
*/
export async function getSystemPerformance(timeRange: string = '7d'): Promise<SystemPerformance> {
const response = await api.get<SystemPerformance>('/api/v1/analytics/system/performance', {
params: { time_range: timeRange }
});
return response.data;
}
/**
* Get localization accuracy distribution
*/
export async function getAccuracyDistribution(timeRange: string = '7d'): Promise<{
accuracy_ranges: string[];
counts: number[];
}> {
const response = await api.get<{
accuracy_ranges: string[];
counts: number[];
}>('/api/v1/analytics/localizations/accuracy-distribution', {
params: { time_range: timeRange }
});
return response.data;
}
/**
* Dashboard metrics aggregated from various sources
*/
export interface DashboardMetrics {
signalDetections: number;
systemUptime: number;
modelAccuracy: number;
predictionsTotal: number;
predictionsSuccessful: number;
predictionsFailed: number;
lastUpdate: string;
}
/**
* Get aggregated dashboard metrics
*/
export async function getDashboardMetrics(): Promise<DashboardMetrics> {
const response = await api.get<DashboardMetrics>('/api/v1/analytics/dashboard/metrics');
return response.data;
}
const analyticsService = {
getPredictionMetrics,
getWebSDRPerformance,
getSystemPerformance,
getAccuracyDistribution,
getDashboardMetrics,
};
export default analyticsService; |