Fix billing graph when the period is zero or doesn't exist, before the fix a divide by zero error was happening when the billing api was being call for an image (#14623)

This commit is contained in:
Javier Alejandro Ruiz G 2022-11-13 07:53:54 -05:00 committed by GitHub
parent 8176e726bc
commit 5121f10587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,9 +192,9 @@ function getRates($bill_id, $datefrom, $dateto, $dir_95th)
$data['total_data'] = $mtot;
$data['total_data_in'] = $mtot_in;
$data['total_data_out'] = $mtot_out;
$data['rate_average'] = ($mtot / $ptot * 8);
$data['rate_average_in'] = ($mtot_in / $ptot * 8);
$data['rate_average_out'] = ($mtot_out / $ptot * 8);
$data['rate_average'] = ! empty($ptot) ? ($mtot / $ptot * 8) : 0;
$data['rate_average_in'] = ! empty($ptot) ? ($mtot_in / $ptot * 8) : 0;
$data['rate_average_out'] = ! empty($ptot) ? ($mtot_out / $ptot * 8) : 0;
// print_r($data);
return $data;