add active flow route
This commit is contained in:
parent
2149217dc2
commit
1271387131
2 changed files with 47 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use mongod::{Model, Referencable, ToAPI};
|
||||
use mongod::{vec_to_api, Model, Referencable, ToAPI};
|
||||
use mongodb::bson::doc;
|
||||
use rocket::{get, post, serde::json::Json, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
@ -30,6 +31,31 @@ pub async fn flow_info(
|
|||
Ok(flowinfo.api().await)
|
||||
}
|
||||
|
||||
#[get("/flow/<id>/active")]
|
||||
pub async fn active_flows_route(
|
||||
id: &str,
|
||||
flows: &State<JSONStore<FlowInfo>>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let flowinfo = flows.get(id).ok_or_else(|| api_error("Flow not found"))?;
|
||||
|
||||
let flow = Flow::find(
|
||||
doc! {
|
||||
"kind": flowinfo.reference(),
|
||||
"done": { "$not": { "$type": "object" } }
|
||||
},
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
Ok(json!(vec_to_api(&flow).await))
|
||||
}
|
||||
|
||||
#[get("/flows")]
|
||||
pub async fn flows_list(
|
||||
flows: &State<JSONStore<FlowInfo>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue