From cb437f5a746156419230e3772ca17c3f5093a4b5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 11:29:42 +0000 Subject: [PATCH] feat: batch and throttle historical rates fetching - Added `fetchHistoricalRatesBatch` to frontend to bundle dates into a single Tauri IPC call. - Created `fetch_historical_rates_batch` command in Rust backend. - Reused a global `reqwest::Client` via `std::sync::OnceLock` to leverage connection pooling and eliminate TCP/TLS handshake overhead per request. - Used `futures::stream::buffer_unordered` to throttle concurrent requests (max 5) to the external API, preventing rate limits and connection spam while maintaining concurrency benefits. Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- src-tauri/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8e77152..7c6885e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -431,7 +431,6 @@ async fn fetch_historical_rates( Ok(rates) } - #[tauri::command] async fn fetch_historical_rates_batch( app: AppHandle, @@ -446,7 +445,8 @@ async fn fetch_historical_rates_batch( } let cache_path = data_dir(&app).join(format!("rates-{}.json", date)); if let Ok(raw) = std::fs::read_to_string(&cache_path) { - if let Ok(cached) = serde_json::from_str::>(&raw) { + if let Ok(cached) = serde_json::from_str::>(&raw) + { results.insert(date.clone(), cached); continue; }