src/api2/node/tasks.rs: implement userfilter
This commit is contained in:
parent
3c3bee2e32
commit
d2a2e02bb7
|
@ -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,6 +87,10 @@ 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.")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue