fix(server): fix missing /api/graph and task title mapping in dashboard

This commit is contained in:
Riz Ashraf committed 2026-09-12 09:25:15 +01:00
1 parent 36674df176
commit 1f050b60b6
3 files changed
+90 -3

No files matched your search

+38 -2
View File
@@ -268,8 +268,42 @@ fn run_server(state: Arc<MemoryState>) -> Result<(), Box<dyn std::error::Error>>
"/",
get(|| async move { axum::response::Html(include_str!("dashboard.html")) }),
)
.route(
"/api/stats",
.route("/api/graph", get({
let state_clone = app_state.handler.state.clone();
move || async move {
let graph = state_clone.get_full_graph();
axum::Json(graph)
}
}))
.route("/api/tasks", get({
let state_clone = app_state.handler.state.clone();
move || async move {
let tasks = state_clone.tasks.read();
axum::Json(tasks.clone())
}
}))
.route("/api/search", get({
let state_clone = app_state.handler.state.clone();
move |axum::extract::Query(params): axum::extract::Query<std::collections::HashMap<String, String>>| async move {
if let Some(q) = params.get("q") {
if let Ok(idx) = state_clone.search_index.read() {
if let Ok(results) = idx.search(q, None) {
let mut formatted_results = Vec::new();
for (type_name, content) in results {
formatted_results.push(serde_json::json!({
"type_name": type_name,
"content": content,
"score": 1.0
}));
}
return axum::Json(serde_json::json!({ "results": formatted_results }));
}
}
}
axum::Json(serde_json::json!({ "results": [] }))
}
}))
.route("/api/stats",
get({
let state_clone = app_state.handler.state.clone();
move || async move {
@@ -716,3 +750,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
run_server(state)
}