fix: compile processing.rs + mount processing_routes
- Fix 9 compilation errors in processing.rs: - memory_mb typo (mem_mb) - download_json return type - Chunk from_row (use row_to_json) - ProgressResponse/SystemHealthInfo/ProcessorProgressInfo Deserialize - Remove flush_all/flush (methods don't exist) - Add pub mod processing to api/mod.rs - Merge processing::processing_routes() into server router
This commit is contained in:
@@ -4,6 +4,7 @@ pub mod auth;
|
||||
pub mod docs;
|
||||
pub mod files;
|
||||
pub mod five_w1h_agent_api;
|
||||
pub mod processing;
|
||||
pub mod health;
|
||||
pub mod identities;
|
||||
pub mod identity_agent_api;
|
||||
|
||||
@@ -110,7 +110,7 @@ struct ProcessRequest {
|
||||
processors: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct ProgressResponse {
|
||||
file_uuid: String,
|
||||
user: Option<String>,
|
||||
@@ -126,7 +126,7 @@ struct ProgressResponse {
|
||||
processors: Vec<ProcessorProgressInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct SystemHealthInfo {
|
||||
cpu_idle_pct: f64,
|
||||
memory_available_mb: u64,
|
||||
@@ -140,7 +140,7 @@ struct SystemHealthInfo {
|
||||
running_processors: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct ProcessorProgressInfo {
|
||||
name: String,
|
||||
status: String,
|
||||
@@ -281,19 +281,17 @@ async fn download_json(
|
||||
let output_dir = std::env::var("MOMENTRY_OUTPUT_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry/output_dev".to_string());
|
||||
let path = std::path::Path::new(&output_dir).join(format!("{}.{}.json", file_uuid, processor));
|
||||
match tokio::fs::read_to_string(&path).await {
|
||||
Ok(content) => serde_json::from_str(&content).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR),
|
||||
Err(_) => Err(StatusCode::NOT_FOUND),
|
||||
}
|
||||
let content = tokio::fs::read_to_string(&path).await.map_err(|_| StatusCode::NOT_FOUND)?;
|
||||
Ok(Json(serde_json::from_str(&content).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?))
|
||||
}
|
||||
|
||||
async fn get_chunk_by_path(
|
||||
State(state): State<AppState>,
|
||||
Path((file_uuid, chunk_id)): Path<(String, String)>,
|
||||
) -> Result<Json<crate::core::chunk::types::Chunk>, StatusCode> {
|
||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
let table = schema::table_name("chunk");
|
||||
let chunk: Option<crate::core::chunk::types::Chunk> = sqlx::query_as(&format!(
|
||||
"SELECT * FROM {} WHERE uuid = $1 AND chunk_id = $2",
|
||||
let row: Option<serde_json::Value> = sqlx::query_scalar(&format!(
|
||||
"SELECT row_to_json(t) FROM (SELECT * FROM {} WHERE uuid = $1 AND chunk_id = $2) t",
|
||||
table
|
||||
))
|
||||
.bind(&file_uuid)
|
||||
@@ -302,7 +300,7 @@ async fn get_chunk_by_path(
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
chunk.ok_or(StatusCode::NOT_FOUND)
|
||||
row.map(Json).ok_or(StatusCode::NOT_FOUND)
|
||||
}
|
||||
|
||||
async fn get_progress(
|
||||
@@ -354,7 +352,7 @@ async fn get_progress(
|
||||
cpu_percent: cpu,
|
||||
gpu_percent: gpu,
|
||||
memory_percent: mem_pct,
|
||||
memory_mb,
|
||||
memory_mb: mem_mb,
|
||||
system: Some(sys),
|
||||
processors,
|
||||
}))
|
||||
@@ -461,10 +459,6 @@ async fn cache_toggle(
|
||||
Json(req): Json<CacheToggleRequest>,
|
||||
) -> Json<CacheToggleResponse> {
|
||||
crate::core::config::set_cache_enabled(req.enabled);
|
||||
if !req.enabled {
|
||||
let _ = state.mongo_cache.flush_all().await;
|
||||
let _ = state.redis_cache.flush().await;
|
||||
}
|
||||
Json(CacheToggleResponse {
|
||||
success: true,
|
||||
cache_enabled: req.enabled,
|
||||
|
||||
@@ -14,6 +14,7 @@ use super::auth;
|
||||
use super::docs;
|
||||
use super::files;
|
||||
use super::five_w1h_agent_api;
|
||||
use super::processing;
|
||||
use super::health;
|
||||
use super::identities;
|
||||
use super::identity_agent_api;
|
||||
@@ -106,6 +107,7 @@ pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
|
||||
.merge(identity_api::identity_routes())
|
||||
.merge(agent_api::agent_routes())
|
||||
.merge(agent_search::agent_search_routes())
|
||||
.merge(processing::processing_routes())
|
||||
.merge(identity_agent_api::identity_agent_routes())
|
||||
.merge(five_w1h_agent_api::five_w1h_agent_routes())
|
||||
.merge(media_api::bbox_routes())
|
||||
|
||||
Reference in New Issue
Block a user