From: Dominik Csapak <d.csapak@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
Date: Mon, 20 Jul 2020 16:37:24 +0200 [thread overview]
Message-ID: <a4dc0fac-2c50-b303-2796-7fa4653a0cdc@proxmox.com> (raw)
In-Reply-To: <a1f760bc-f5d6-edb7-3fae-01f74b8b5207@proxmox.com>
On 7/20/20 11:36 AM, Thomas Lamprecht wrote:
> On 17.07.20 15:39, Dominik Csapak wrote:
>> when a datastore has enough data to calculate the estimated full date,
>> but always has exactly the same usage, the factor b of the regression
>> is '0'
>>
>> return 0 for that case so that the gui can show 'never' instead of
>> 'not enough data'
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> src/api2/status.rs | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/src/api2/status.rs b/src/api2/status.rs
>> index 34e0505..4f98543 100644
>> --- a/src/api2/status.rs
>> +++ b/src/api2/status.rs
>> @@ -161,6 +161,8 @@ fn datastore_status(
>> if b != 0.0 {
>> let estimate = (1.0 - a) / b;
>> entry["estimated-full-date"] = Value::from(estimate.floor() as u64);
>> + } else {
>> + entry["estimated-full-date"] = Value::from(0);
>> }
>> }
>> }
>>
>
> nit and asking mostly out of interest, but wouldn't it be more "idomatic rust" if this
> was written like:
>
> entry["estimated-full-date"] = if b != 0.0 {
> let estimate = (1.0 - a) / b;
> Value::from(estimate.floor() as u64)
> } else {
> Value::from(0)
> }
>
> anyway, looks OK to me from a quick look.
>
yes, probably... i personally find those multiline let foo = if {..}
statements a bit harder to read...
should i send a v2?
next prev parent reply other threads:[~2020-07-20 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 13:39 Dominik Csapak
2020-07-17 13:39 ` [pbs-devel] [PATCH proxmox-backup 2/2] examples/upload-speed: adapt to change Dominik Csapak
2020-07-20 8:22 ` [pbs-devel] applied: " Fabian Grünbichler
2020-07-20 9:36 ` [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug Thomas Lamprecht
2020-07-20 14:37 ` Dominik Csapak [this message]
2020-07-20 14:48 ` Thomas Lamprecht
2020-07-21 11:10 ` [pbs-devel] applied: " Thomas Lamprecht
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=a4dc0fac-2c50-b303-2796-7fa4653a0cdc@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=t.lamprecht@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