summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers/mesh.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/server/handlers/mesh.rs')
-rw-r--r--makima/src/server/handlers/mesh.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/makima/src/server/handlers/mesh.rs b/makima/src/server/handlers/mesh.rs
index 1a5b9c1..ac5652a 100644
--- a/makima/src/server/handlers/mesh.rs
+++ b/makima/src/server/handlers/mesh.rs
@@ -78,10 +78,24 @@ pub fn extract_auth(state: &SharedState, headers: &HeaderMap) -> AuthSource {
// Task Handlers
// =============================================================================
-/// List all tasks for the current owner.
+/// Query parameters for `list_tasks`. Currently only the `orphan` filter —
+/// when set, returns tasks with NO parent_task_id AND NO directive_id, used
+/// by the document-mode sidebar's `tmp/` folder.
+#[derive(Debug, serde::Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ListTasksQuery {
+ #[serde(default)]
+ pub orphan: bool,
+}
+
+/// List all tasks for the current owner. Pass `?orphan=true` to restrict to
+/// top-level tasks with no directive attachment.
#[utoipa::path(
get,
path = "/api/v1/mesh/tasks",
+ params(
+ ("orphan" = Option<bool>, Query, description = "Filter to tasks with no directive_id and no parent_task_id"),
+ ),
responses(
(status = 200, description = "List of tasks", body = TaskListResponse),
(status = 401, description = "Unauthorized", body = ApiError),
@@ -97,6 +111,7 @@ pub fn extract_auth(state: &SharedState, headers: &HeaderMap) -> AuthSource {
pub async fn list_tasks(
State(state): State<SharedState>,
Authenticated(auth): Authenticated,
+ axum::extract::Query(query): axum::extract::Query<ListTasksQuery>,
) -> impl IntoResponse {
let Some(ref pool) = state.db_pool else {
return (
@@ -106,7 +121,13 @@ pub async fn list_tasks(
.into_response();
};
- match repository::list_tasks_for_owner(pool, auth.owner_id).await {
+ let result = if query.orphan {
+ repository::list_orphan_tasks_for_owner(pool, auth.owner_id).await
+ } else {
+ repository::list_tasks_for_owner(pool, auth.owner_id).await
+ };
+
+ match result {
Ok(tasks) => {
let total = tasks.len() as i64;
Json(TaskListResponse { tasks, total }).into_response()