From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager] server: tasks: fix filter order
Date: Fri, 22 Aug 2025 14:11:49 +0200 [thread overview]
Message-ID: <20250822121553.3255195-1-d.csapak@proxmox.com> (raw)
commit
bd0babf (remote tasks: add background task for task polling, use new task cache)
changed the order of filters applied to the task list, namely it put the
skip and limit at the front of the filtering, instead of the back.
Since we use these paramters in the ui to batch loads, we don't want to
first limit our numbers and then filter on them, but first apply the
filters and then limit the amount, otherwise we could never show older
tasks when filtered.
An example:
Assume the ui usess 'limit=5' to batch the loads
if the user wants to show only those tasks with 'statusfilter=warning'
but we first have 10 'OK' tasks, we'd never show anything, since the api
would return an empty list, even if we'd have multiple warning tasks
after that.
In contrast if we filter first and then limit the number/apply the
offset, we would get the first five tasks that ended with a warning,
like we would expect.
To fix that, move the skip/take filters at the end.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
server/src/remote_tasks/mod.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs
index 8638ebd..63a279a 100644
--- a/server/src/remote_tasks/mod.rs
+++ b/server/src/remote_tasks/mod.rs
@@ -38,8 +38,6 @@ pub async fn get_tasks(filters: TaskFilters) -> Result<Vec<TaskListItem>, Error>
let returned_tasks = cache
.get_tasks(which)?
- .skip(filters.start as usize)
- .take(filters.limit as usize)
.filter_map(|task| {
// TODO: Handle PBS tasks
let pve_upid: Result<PveUpid, Error> = task.upid.upid.parse();
@@ -106,6 +104,8 @@ pub async fn get_tasks(filters: TaskFilters) -> Result<Vec<TaskListItem>, Error>
true
})
+ .skip(filters.start as usize)
+ .take(filters.limit as usize)
.collect();
Ok(returned_tasks)
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next reply other threads:[~2025-08-22 12:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 12:11 Dominik Csapak [this message]
2025-08-22 13:21 ` [pdm-devel] applied: " Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250822121553.3255195-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox