refactor: improved performance for old profiles

This commit is contained in:
zhom
2025-11-30 17:34:04 +04:00
parent e16512576c
commit c40f023d41
5 changed files with 272 additions and 128 deletions
+13 -7
View File
@@ -247,11 +247,6 @@ async fn is_geoip_database_available() -> Result<bool, String> {
Ok(GeoIPDownloader::is_geoip_database_available())
}
#[tauri::command]
async fn get_all_traffic_stats() -> Result<Vec<crate::traffic_stats::TrafficStats>, String> {
Ok(crate::traffic_stats::list_traffic_stats())
}
#[tauri::command]
async fn get_all_traffic_snapshots() -> Result<Vec<crate::traffic_stats::TrafficSnapshot>, String> {
Ok(
@@ -268,6 +263,17 @@ async fn clear_all_traffic_stats() -> Result<(), String> {
.map_err(|e| format!("Failed to clear traffic stats: {e}"))
}
#[tauri::command]
async fn get_traffic_stats_for_period(
profile_id: String,
seconds: u64,
) -> Result<Option<crate::traffic_stats::FilteredTrafficStats>, String> {
Ok(crate::traffic_stats::get_traffic_stats_for_period(
&profile_id,
seconds,
))
}
#[tauri::command]
async fn download_geoip_database(app_handle: tauri::AppHandle) -> Result<(), String> {
let downloader = GeoIPDownloader::instance();
@@ -779,9 +785,9 @@ pub fn run() {
start_api_server,
stop_api_server,
get_api_server_status,
get_all_traffic_stats,
get_all_traffic_snapshots,
clear_all_traffic_stats
clear_all_traffic_stats,
get_traffic_stats_for_period
])
.run(tauri::generate_context!())
.expect("error while running tauri application");