From 69a972e0d9af27b9db42440c12ae6f615ad7ce25 Mon Sep 17 00:00:00 2001 From: cp6 Date: Thu, 22 Sep 2022 12:26:56 +1000 Subject: [PATCH] Updated & fixed YABS JSON parser Fixed ram conversion Fixed disk conversion Fixed disk speed conversion --- app/Models/Yabs.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Models/Yabs.php b/app/Models/Yabs.php index 5df5a5e..0aa9c40 100644 --- a/app/Models/Yabs.php +++ b/app/Models/Yabs.php @@ -196,7 +196,7 @@ class Yabs extends Model $yabs_id = Str::random(8); - if ($ram > 10) { + if ($ram > 999999) { $ram_f = ($ram / 1024 / 1024); $ram_type = 'GB'; } else { @@ -204,11 +204,11 @@ class Yabs extends Model $ram_type = 'MB'; } - if ($disk > 10000) { - $disk_f = ($disk / 1024 / 1024); + if ($disk > 100000000) { + $disk_f = ($disk / 1024 / 1024 / 1024); $disk_type = 'TB'; } else { - $disk_f = ($disk / 1024); + $disk_f = ($disk / 1024 / 1024); $disk_type = 'GB'; } @@ -242,23 +242,23 @@ class Yabs extends Model //Fio foreach ($data['fio'] as $ds) { if ($ds['bs'] === '4k') { - $d4k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw']; - $d4k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s'; + $d4k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; + $d4k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d4k_mbps = self::KBstoMBs($ds['speed_rw']); } if ($ds['bs'] === '64k') { - $d64k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw']; - $d64k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s'; + $d64k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; + $d64k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d64k_mbps = self::KBstoMBs($ds['speed_rw']); } if ($ds['bs'] === '512k') { - $d512k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw']; - $d512k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s'; + $d512k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; + $d512k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d512k_mbps = self::KBstoMBs($ds['speed_rw']); } if ($ds['bs'] === '1m') { - $d1m = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw']; - $d1m_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s'; + $d1m = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; + $d1m_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d1m_mbps = self::KBstoMBs($ds['speed_rw']); } }