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 6CB3A1FF189 for ; Fri, 8 Aug 2025 12:29:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA8C7140F0; Fri, 8 Aug 2025 12:30:58 +0200 (CEST) Message-ID: <18660d1f-a53c-4fdc-8148-701e6e2587e6@proxmox.com> Date: Fri, 8 Aug 2025 12:30:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: pmg-devel@lists.proxmox.com References: <20250804110327.27691-1-h.laimer@proxmox.com> Content-Language: en-US From: Hannes Laimer In-Reply-To: <20250804110327.27691-1-h.laimer@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1754649031611 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 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] superseded: [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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" superseded-by: https://lore.proxmox.com/pmg-devel/20250808102836.50441-1-h.laimer@proxmox.com/T/#u On 04.08.25 13:03, Hannes Laimer wrote: > 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"; > } _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel