public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
@ 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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dominik Csapak @ 2020-07-17 13:39 UTC (permalink / raw)
  To: pbs-devel

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);
                         }
                     }
                 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] examples/upload-speed: adapt to change
  2020-07-17 13:39 [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug Dominik Csapak
@ 2020-07-17 13:39 ` 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-21 11:10 ` [pbs-devel] applied: " Thomas Lamprecht
  2 siblings, 1 reply; 7+ messages in thread
From: Dominik Csapak @ 2020-07-17 13:39 UTC (permalink / raw)
  To: pbs-devel

commit 323b2f3dd6364119f2ffcd7397161e9f56cdb3fc
changed the signature of upload_speedtest
adapt the example

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 examples/upload-speed.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/upload-speed.rs b/examples/upload-speed.rs
index b438c49..8594d6e 100644
--- a/examples/upload-speed.rs
+++ b/examples/upload-speed.rs
@@ -2,7 +2,7 @@ use anyhow::{Error};
 
 use proxmox_backup::client::*;
 
-async fn upload_speed() -> Result<usize, Error> {
+async fn upload_speed() -> Result<f64, Error> {
 
     let host = "localhost";
     let datastore = "store2";
@@ -20,7 +20,7 @@ async fn upload_speed() -> Result<usize, Error> {
     let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false).await?;
 
     println!("start upload speed test");
-    let res = client.upload_speedtest().await?;
+    let res = client.upload_speedtest(true).await?;
 
     Ok(res)
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup 2/2] examples/upload-speed: adapt to change
  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   ` Fabian Grünbichler
  0 siblings, 0 replies; 7+ messages in thread
From: Fabian Grünbichler @ 2020-07-20  8:22 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

On July 17, 2020 3:39 pm, Dominik Csapak wrote:
> commit 323b2f3dd6364119f2ffcd7397161e9f56cdb3fc
> changed the signature of upload_speedtest
> adapt the example
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  examples/upload-speed.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/upload-speed.rs b/examples/upload-speed.rs
> index b438c49..8594d6e 100644
> --- a/examples/upload-speed.rs
> +++ b/examples/upload-speed.rs
> @@ -2,7 +2,7 @@ use anyhow::{Error};
>  
>  use proxmox_backup::client::*;
>  
> -async fn upload_speed() -> Result<usize, Error> {
> +async fn upload_speed() -> Result<f64, Error> {
>  
>      let host = "localhost";
>      let datastore = "store2";
> @@ -20,7 +20,7 @@ async fn upload_speed() -> Result<usize, Error> {
>      let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false).await?;
>  
>      println!("start upload speed test");
> -    let res = client.upload_speedtest().await?;
> +    let res = client.upload_speedtest(true).await?;
>  
>      Ok(res)
>  }
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
  2020-07-17 13:39 [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug 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  9:36 ` Thomas Lamprecht
  2020-07-20 14:37   ` Dominik Csapak
  2020-07-21 11:10 ` [pbs-devel] applied: " Thomas Lamprecht
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Lamprecht @ 2020-07-20  9:36 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

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.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
  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
  2020-07-20 14:48     ` Thomas Lamprecht
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Csapak @ 2020-07-20 14:37 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox Backup Server development discussion

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?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
  2020-07-20 14:37   ` Dominik Csapak
@ 2020-07-20 14:48     ` Thomas Lamprecht
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Lamprecht @ 2020-07-20 14:48 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

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@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup 1/2] api2/status: fix estimation bug
  2020-07-17 13:39 [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug 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  9:36 ` [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug Thomas Lamprecht
@ 2020-07-21 11:10 ` Thomas Lamprecht
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Lamprecht @ 2020-07-21 11:10 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

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(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-21 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 13:39 [pbs-devel] [PATCH proxmox-backup 1/2] api2/status: fix estimation bug 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
2020-07-20 14:48     ` Thomas Lamprecht
2020-07-21 11:10 ` [pbs-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal