cleanup: remove dead code and duplicate docs

- Remove session-ses_2f27.md (161KB raw session log)
- Remove 49 ROOT_* duplicate files across REFERENCE/
- Remove 14 duplicate files between REFERENCE/ root and history/
- Remove asr_legacy.rs (dead code, replaced by asr.rs)
- Remove src/core/worker/ (duplicate JobWorker)
- Remove src/core/layers/ (empty directory)
- Remove 4 .bak files in src/
- Remove 7 dead private methods in worker/processor.rs
- Remove backup directory from git tracking
This commit is contained in:
Warren
2026-05-04 01:31:21 +08:00
parent ee81e343ce
commit e75c4d6f07
3270 changed files with 35190 additions and 53367 deletions

View File

@@ -4,7 +4,6 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct VideosResponse {
pub videos: Vec<serde_json::Value>,
#[serde(rename = "count", default)]
pub total: i64,
pub page: usize,
pub page_size: usize,
@@ -16,11 +15,13 @@ pub async fn get_videos(
status: Option<String>,
page: Option<usize>,
page_size: Option<usize>,
uuid: Option<String>,
) -> Result<VideosResponse, String> {
let config = get_config();
let client = reqwest::Client::new();
let mut url = format!("{}/api/v1/videos", config.api_base_url);
// Use /api/v1/files endpoint
let mut url = format!("{}/api/v1/files", config.api_base_url);
let mut params = Vec::new();
if let Some(q) = query {
@@ -35,6 +36,9 @@ pub async fn get_videos(
if let Some(ps) = page_size {
params.push(format!("page_size={}", ps));
}
if let Some(u) = uuid {
params.push(format!("uuid={}", u));
}
if !params.is_empty() {
url.push('?');
@@ -52,12 +56,31 @@ pub async fn get_videos(
return Err(format!("API returned error: {}", response.status()));
}
let result: VideosResponse = response
let json: serde_json::Value = response
.json()
.await
.map_err(|e| format!("Failed to parse API response: {}", e))?;
Ok(result)
// Extract fields from the new API response format
let data = json
.get("data")
.and_then(|v| v.as_array())
.cloned()
.unwrap_or_else(|| vec![]);
let total = json.get("total").and_then(|v| v.as_i64()).unwrap_or(0);
let page_val = json.get("page").and_then(|v| v.as_u64()).unwrap_or(1) as usize;
let page_size_val = json
.get("page_size")
.and_then(|v| v.as_u64())
.unwrap_or(20) as usize;
Ok(VideosResponse {
videos: data,
total,
page: page_val,
page_size: page_size_val,
})
}
#[tauri::command]
@@ -66,14 +89,18 @@ pub async fn list_videos(
page: Option<usize>,
page_size: Option<usize>,
) -> Result<VideosResponse, String> {
get_videos(query, None, page, page_size).await
get_videos(query, None, page, page_size, None).await
}
#[tauri::command]
pub async fn get_video_faces(file_uuid: String) -> Result<serde_json::Value, String> {
let config = get_config();
let client = reqwest::Client::new();
let url = format!("{}/api/v1/videos/{}/faces", config.api_base_url, file_uuid);
// Use new endpoint: /api/v1/face/list?file_uuid=...
let url = format!(
"{}/api/v1/face/list?file_uuid={}",
config.api_base_url, file_uuid
);
let response = client
.get(&url)
@@ -117,3 +144,36 @@ pub async fn get_chunk_detail(uuid: String, chunk_id: String) -> Result<serde_js
.await
.map_err(|e| format!("Failed to parse response: {}", e))
}
#[tauri::command]
pub async fn unregister_video(file_uuid: String) -> Result<serde_json::Value, String> {
let config = get_config();
let client = reqwest::Client::new();
// Use new endpoint: POST /api/v1/unregister
let url = format!("{}/api/v1/unregister", config.api_base_url);
let response = client
.post(&url)
.header("x-api-key", &config.api_key)
.header("Content-Type", "application/json")
.body(serde_json::to_string(&serde_json::json!({ "uuid": file_uuid })).unwrap())
.send()
.await
.map_err(|e| format!("Request failed: {}", e))?;
if !response.status().is_success() {
return Err(format!("API error: {}", response.status()));
}
let mut result: serde_json::Value = response
.json()
.await
.map_err(|e| format!("Failed to parse response: {}", e))?;
// Add file_uuid to match frontend expectation
if let Some(obj) = result.as_object_mut() {
obj.insert("file_uuid".to_string(), serde_json::Value::String(file_uuid.clone()));
}
Ok(result)
}