From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager v2 2/7] server: api: remote tasks: add 'remote' filter option
Date: Wed, 19 Feb 2025 13:28:19 +0100 [thread overview]
Message-ID: <20250219122824.2043990-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250219122824.2043990-1-d.csapak@proxmox.com>
so we can filter the tasks by remote
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
server/src/api/remote_tasks.rs | 17 +++++++++++++----
server/src/task_cache.rs | 11 ++++++++++-
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/server/src/api/remote_tasks.rs b/server/src/api/remote_tasks.rs
index 57b59fd..d327272 100644
--- a/server/src/api/remote_tasks.rs
+++ b/server/src/api/remote_tasks.rs
@@ -1,5 +1,6 @@
use anyhow::Error;
-use pdm_api_types::{TaskFilters, TaskListItem};
+
+use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, TaskFilters, TaskListItem};
use proxmox_router::{list_subdirs_api_method, Permission, Router, SubdirMap};
use proxmox_schema::api;
use proxmox_sortable_macro::sortable;
@@ -31,13 +32,21 @@ const SUBDIRS: SubdirMap = &sorted!([("list", &Router::new().get(&API_METHOD_LIS
filters: {
type: TaskFilters,
flatten: true,
- }
+ },
+ remote: {
+ schema: REMOTE_ID_SCHEMA,
+ optional: true,
+ },
},
},
)]
/// Get the list of tasks for all remotes.
-async fn list_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskListItem>, Error> {
- let tasks = task_cache::get_tasks(max_age, filters).await?;
+async fn list_tasks(
+ max_age: i64,
+ filters: TaskFilters,
+ remote: Option<String>,
+) -> Result<Vec<TaskListItem>, Error> {
+ let tasks = task_cache::get_tasks(max_age, filters, remote).await?;
Ok(tasks)
}
diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs
index 4c34827..c5e8956 100644
--- a/server/src/task_cache.rs
+++ b/server/src/task_cache.rs
@@ -20,7 +20,11 @@ use crate::{api::pve, task_utils};
/// Get tasks for all remotes
// FIXME: filter for privileges
-pub async fn get_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskListItem>, Error> {
+pub async fn get_tasks(
+ max_age: i64,
+ filters: TaskFilters,
+ remote_filter: Option<String>,
+) -> Result<Vec<TaskListItem>, Error> {
let (remotes, _) = pdm_config::remotes::config()?;
let mut all_tasks = Vec::new();
@@ -37,6 +41,11 @@ pub async fn get_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskLis
invalidate_cache_for_finished_tasks(&mut cache);
for (remote_name, remote) in &remotes.sections {
+ if let Some(remote_filter) = &remote_filter {
+ if remote_name != remote_filter {
+ continue;
+ }
+ }
let now = proxmox_time::epoch_i64();
if let Some(tasks) = cache.get_tasks(remote_name.as_str(), now, max_age) {
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-02-19 12:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 12:28 [pdm-devel] [PATCH datacenter-manager v2 0/7] add task summary panels in dashboard Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 1/7] server: task cache: treat a limit of 0 as unbounded Dominik Csapak
2025-02-19 12:28 ` Dominik Csapak [this message]
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 3/7] server: api: add remote-tasks statistics Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 4/7] ui: refactor remote upid formatter Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 5/7] ui: tasks: add helper to summarize task categories Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 6/7] ui: add dialog to show filtered tasks Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 7/7] ui: dashboard: add task summaries Dominik Csapak
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=20250219122824.2043990-3-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal