[pbs-devel] [PATCH proxmox-backup 5/6] api2/node/tasks: add optional until filter

Dominik Csapak d.csapak at proxmox.com
Fri Oct 30 15:02:14 CET 2020


so that users select specific time ranges with 'since' and 'until'
(e.g. a single day)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/node/tasks.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs
index 8fe2aac1..a638b04f 100644
--- a/src/api2/node/tasks.rs
+++ b/src/api2/node/tasks.rs
@@ -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,
-- 
2.20.1






More information about the pbs-devel mailing list