Files
Psychotoxical-psysonic/src-tauri/src/library_analysis_backfill/mod.rs
T
cucadmuh b24a7fc5cb fix(analysis): native library backfill coordinator for advanced strategy (#881)
* feat(analysis): native library backfill coordinator for advanced strategy

Move advanced analytics scheduling from the webview loop into a Rust
background worker (configure + spawn_blocking batch/enqueue), matching
cover backfill. Scan hash+BPM gap tracks instead of the full library;
suppress low-priority analysis UI events; limit loudness refresh IPC to
the playback window.

* fix(analysis): flat backfill configure IPC and restore probe track-perf

Use flattened Tauri args like cover backfill so release/prod invoke works;
keep emitting analysis:track-perf for library low-priority work so Performance
Probe tpm/last-track stats update while waveform/enrichment UI events stay suppressed.

* chore(analysis): fix clippy and drop duplicate TS backfill policy

Allow too_many_arguments on library_analysis_backfill_configure for CI;
remove unused frontend batch API and TS watermark helpers now owned in Rust;
clarify analysis_emits_ui_events comment for low-priority track-perf.

* docs: CHANGELOG and credits for PR #881 native analysis backfill
2026-05-28 10:49:31 +03:00

60 lines
1.6 KiB
Rust

//! Library analysis backfill — native coordinator (advanced analytics strategy).
mod worker;
use std::sync::Arc;
use tauri::{AppHandle, Manager};
use worker::{
spawn_coordinator, setup_library_sync_idle_listener, LibraryAnalysisBackfillSession,
LibraryAnalysisBackfillWorker,
};
pub fn init_library_analysis_backfill(app: &AppHandle) -> Result<(), String> {
let worker = Arc::new(LibraryAnalysisBackfillWorker::new());
app.manage(worker.clone());
setup_library_sync_idle_listener(app);
spawn_coordinator(app, worker);
Ok(())
}
#[tauri::command]
#[allow(clippy::too_many_arguments)] // Tauri command surface — args map 1:1 to the JS call (like cover configure + workers).
pub async fn library_analysis_backfill_configure(
app: AppHandle,
enabled: bool,
server_index_key: String,
library_server_id: String,
server_url: String,
username: String,
password: String,
workers: u32,
) -> Result<(), String> {
let worker = app
.try_state::<Arc<LibraryAnalysisBackfillWorker>>()
.ok_or_else(|| "library analysis backfill worker not initialized".to_string())?;
let session = if enabled
&& !server_index_key.is_empty()
&& !library_server_id.is_empty()
&& !server_url.is_empty()
{
Some(LibraryAnalysisBackfillSession {
server_index_key,
library_server_id,
server_url,
username,
password,
workers: workers.max(1),
})
} else {
None
};
worker
.set_session(enabled && session.is_some(), session)
.await;
Ok(())
}