From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A2D271FF185 for ; Mon, 4 Aug 2025 13:02:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E65231E6A1; Mon, 4 Aug 2025 13:04:10 +0200 (CEST) From: Hannes Laimer To: pmg-devel@lists.proxmox.com Date: Mon, 4 Aug 2025 13:03:27 +0200 Message-ID: <20250804110327.27691-1-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1754305399310 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.025 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] [PATCH pmg-api] fix #2452: pmgqm: allow h to be used as a timespan X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" Signed-off-by: Hannes Laimer --- came up in enterprise support src/PMG/CLI/pmgqm.pm | 8 ++++---- src/PMG/Utils.pm | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm index 23968f2..9ff6097 100755 --- a/src/PMG/CLI/pmgqm.pm +++ b/src/PMG/CLI/pmgqm.pm @@ -90,9 +90,9 @@ __PACKAGE__->register_method({ additionalProperties => 0, properties => { timespan => { - description => "Select time span.", + description => "Select time span. h refers to the past x hours.", type => 'string', - enum => ['today', 'yesterday', 'week'], + pattern => '^(today|yesterday|week|(?:[1-9]|1[0-9]|2[0-3])h)$', default => 'today', optional => 1, }, @@ -167,9 +167,9 @@ __PACKAGE__->register_method({ }, ), timespan => { - description => "Select time span.", + description => "Select time span. h refers to the past x hours.", type => 'string', - enum => ['today', 'yesterday', 'week'], + pattern => '^(today|yesterday|week|(?:[1-9]|1[0-9]|2[0-3])h)$', default => 'today', optional => 1, }, diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm index 890096f..d922e7c 100644 --- a/src/PMG/Utils.pm +++ b/src/PMG/Utils.pm @@ -1407,6 +1407,10 @@ sub lookup_timespan { } elsif ($timespan eq 'week') { $end = $daystart; $start = $end - 7 * 86400; + } elsif ($timespan =~ /^(\d+)h$/) { + my $hours = $1; + $end = time(); + $start = $end - ($hours * 3600); } else { die "internal error"; } -- 2.47.2 _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel