From: Hannes Laimer <h.laimer@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] superseded: [PATCH pmg-api] fix #2452: pmgqm: allow <x>h to be used as a timespan
Date: Fri, 8 Aug 2025 12:30:55 +0200 [thread overview]
Message-ID: <18660d1f-a53c-4fdc-8148-701e6e2587e6@proxmox.com> (raw)
In-Reply-To: <20250804110327.27691-1-h.laimer@proxmox.com>
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 <h.laimer@proxmox.com>
> ---
> 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. <x>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. <x>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
prev parent reply other threads:[~2025-08-08 10:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 11:03 [pmg-devel] " Hannes Laimer
2025-08-08 10:30 ` Hannes Laimer [this message]
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=18660d1f-a53c-4fdc-8148-701e6e2587e6@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pmg-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