[pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Jul 20 16:48:27 CEST 2020
On 20.07.20 16:37, Dominik Csapak wrote:
> 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 at 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?
no, just for that definitively not.
More information about the pbs-devel
mailing list