src/api2/node/tasks.rs: implement userfilter

This commit is contained in:
Dietmar Maurer 2019-04-07 13:17:19 +02:00
parent 3c3bee2e32
commit d2a2e02bb7
1 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,8 @@ fn list_tasks(
let limit = param["limit"].as_u64().unwrap_or(50); let limit = param["limit"].as_u64().unwrap_or(50);
let errors = param["errors"].as_bool().unwrap_or(false); let errors = param["errors"].as_bool().unwrap_or(false);
let userfilter = param["userfilter"].as_str();
let list = server::read_task_list()?; let list = server::read_task_list()?;
let mut result = vec![]; let mut result = vec![];
@ -35,6 +37,10 @@ fn list_tasks(
"user": info.upid.username, "user": info.upid.username,
}); });
if let Some(username) = userfilter {
if !info.upid.username.contains(username) { continue; }
}
if let Some(ref state) = info.state { if let Some(ref state) = info.state {
if errors && state.1 == "OK" { if errors && state.1 == "OK" {
continue; continue;
@ -81,7 +87,11 @@ pub fn router() -> Router {
"errors", "errors",
BooleanSchema::new("Only list erroneous tasks.") BooleanSchema::new("Only list erroneous tasks.")
) )
) .optional(
"userfilter",
StringSchema::new("Only list tasks from this user.")
)
)
); );
route route