fix: report endpoint reads report.md from workspace, clean ReportView
This commit is contained in:
@@ -16,6 +16,7 @@ use super::{ApiResult, db_err};
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct ReportResponse {
|
||||
project_id: String,
|
||||
report: String,
|
||||
}
|
||||
|
||||
@@ -181,11 +182,25 @@ async fn get_report(
|
||||
.await
|
||||
.map_err(db_err)?;
|
||||
|
||||
match wf {
|
||||
Some(w) if !w.report.is_empty() => Ok(Json(ReportResponse { report: w.report })),
|
||||
Some(_) => Err((StatusCode::NOT_FOUND, "Report not yet generated").into_response()),
|
||||
None => Err((StatusCode::NOT_FOUND, "Workflow not found").into_response()),
|
||||
let wf = match wf {
|
||||
Some(w) => w,
|
||||
None => return Err((StatusCode::NOT_FOUND, "Workflow not found").into_response()),
|
||||
};
|
||||
|
||||
// Read report.md from workspace
|
||||
let workspace_root = if std::path::Path::new("/app/data/workspaces").is_dir() {
|
||||
"/app/data/workspaces"
|
||||
} else {
|
||||
"data/workspaces"
|
||||
};
|
||||
let report_path = format!("{}/{}/report.md", workspace_root, wf.project_id);
|
||||
let report = tokio::fs::read_to_string(&report_path).await.unwrap_or_default();
|
||||
|
||||
if report.is_empty() {
|
||||
return Err((StatusCode::NOT_FOUND, "report.md not found").into_response());
|
||||
}
|
||||
|
||||
Ok(Json(ReportResponse { project_id: wf.project_id, report }))
|
||||
}
|
||||
|
||||
async fn get_plan(
|
||||
|
||||
Reference in New Issue
Block a user