]> git.proxmox.com Git - proxmox-backup.git/commitdiff
api2/node/tasks: add optional until filter
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 30 Oct 2020 14:02:14 +0000 (15:02 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 3 Nov 2020 10:35:21 +0000 (11:35 +0100)
so that users select specific time ranges with 'since' and 'until'
(e.g. a single day)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/api2/node/tasks.rs

index 8fe2aac1d6ce7444e02114def96fd20fc7bc0288..a638b04f31519a8778babcdedf0ba7c94098c203 100644 (file)
@@ -301,6 +301,11 @@ fn stop_task(
                 description: "Only list tasks since this UNIX epoch.",
                 optional: true,
             },
+            until: {
+                type: i64,
+                description: "Only list tasks until this UNIX epoch.",
+                optional: true,
+            },
             typefilter: {
                 optional: true,
                 type: String,
@@ -334,6 +339,7 @@ pub fn list_tasks(
     running: bool,
     userfilter: Option<String>,
     since: Option<i64>,
+    until: Option<i64>,
     typefilter: Option<String>,
     statusfilter: Option<Vec<TaskStateType>>,
     param: Value,
@@ -352,6 +358,13 @@ pub fn list_tasks(
     let limit = if limit > 0 { limit as usize } else { usize::MAX };
 
     let result: Vec<TaskListItem> = list
+        .skip_while(|info| {
+            match (info, until) {
+                (Ok(info), Some(until)) => info.upid.starttime > until,
+                (Ok(_), None) => false,
+                (Err(_), _) => false,
+            }
+        })
         .take_while(|info| {
             match (info, since) {
                 (Ok(info), Some(since)) => info.upid.starttime > since,