From ee8651b82eaafb364dbb9c5d33e5ea12bcf94c1d Mon Sep 17 00:00:00 2001 From: cp6 Date: Tue, 26 Jan 2021 00:15:46 +1100 Subject: [PATCH] Fixed all speed tests being bust cases query failure Added has_st col (has speed test) this means you can now have YABs data, YABs data but no speedtest (becasue they were all busy) or no YABs data. --- class.php | 32 +++++++++++++++++++++++++------- update.sql | 16 +++++++++++++++- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/class.php b/class.php index cd52793..5774c95 100644 --- a/class.php +++ b/class.php @@ -693,13 +693,13 @@ class idlers extends helperFunctions public function serverData(string $id) { - $select = $this->dbConnect()->prepare("SELECT `has_yabs` FROM `servers` WHERE `id` = ? LIMIT 1;"); + $select = $this->dbConnect()->prepare("SELECT `has_yabs`, `has_st` FROM `servers` WHERE `id` = ? LIMIT 1;"); $select->execute([$id]); $row = $select->fetch(); - if ($row['has_yabs'] == 1) { + if ($row['has_yabs'] == 1 && $row['has_st'] == 1) { $select = $this->dbConnect()->prepare(" SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type,bandwidth,bandwidth_type,gb5_single,gb5_multi,gb5_id,aes_ni,amd_v, - is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,ns1,ns2,DATE_FORMAT(`owned_since`, '%M %Y') as owned_since, `owned_since` as owned_since_raw, `4k`,`4k_type`,`64k`,`64k_type`,`512k`,`512k_type`,`1m`,`1m_type`, + is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,has_st,ns1,ns2,DATE_FORMAT(`owned_since`, '%M %Y') as owned_since, `owned_since` as owned_since_raw, `4k`,`4k_type`,`64k`,`64k_type`,`512k`,`512k_type`,`1m`,`1m_type`, loc.name as location,send,send_type,recieve,recieve_type,price,currency,term,as_usd,per_month,next_dd,pr.name as provider FROM servers INNER JOIN disk_speed ds on servers.id = ds.server_id INNER JOIN speed_tests st on servers.id = st.server_id INNER JOIN locations loc on servers.location = loc.id @@ -711,6 +711,17 @@ class idlers extends helperFunctions $speed_tests = $sel_st->fetchAll(PDO::FETCH_ASSOC); $final = array_merge($speed_tests, $data); return json_encode($final); + } elseif ($row['has_yabs'] == 1 && $row['has_st'] == 0) { + $select = $this->dbConnect()->prepare(" + SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type,bandwidth,bandwidth_type,gb5_single,gb5_multi,gb5_id,aes_ni,amd_v, + is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,has_st,ns1,ns2,DATE_FORMAT(`owned_since`, '%M %Y') as owned_since, `owned_since` as owned_since_raw, `4k`,`4k_type`,`64k`,`64k_type`,`512k`,`512k_type`,`1m`,`1m_type`, + loc.name as location,price,currency,term,as_usd,per_month,next_dd,pr.name as provider + FROM servers INNER JOIN disk_speed ds on servers.id = ds.server_id + INNER JOIN locations loc on servers.location = loc.id + INNER JOIN providers pr on servers.provider = pr.id INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;"); + $select->execute([$id]); + $data = $select->fetchAll(PDO::FETCH_ASSOC)[0]; + return json_encode($data); } else { $select = $this->dbConnect()->prepare(" SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type, @@ -1891,6 +1902,7 @@ class idlers extends helperFunctions $ipv6 = $data['ipv6']; } ($data['has_yabs'] == 1) ? $has_yabs = true : $has_yabs = false; + ($data['has_st'] == 1) ? $has_st = true : $has_st = false; $this->tagOpen('div', 'modal-header'); $this->HTMLphrase('h4', 'modal-title w-100', $data['hostname'], 'view_more_header'); $this->outputString(''); @@ -2109,7 +2121,7 @@ class idlers extends helperFunctions $this->colOpen('col-2'); $this->HTMLphrase('p', 'm-value', $data['virt']); $this->tagClose('div', 2); - if ($has_yabs) { + if ($has_yabs && $has_st) { $this->rowColOpen('row m-section-row', 'col-12 text-center'); $this->HTMLphrase('p', 'm-section-text', 'Network test'); $this->tagClose('div', 2); @@ -2137,7 +2149,7 @@ class idlers extends helperFunctions $this->rowColOpen('row m-section-row', 'col-12 text-center'); $this->htmlPhrase('p', 'm-section-text', 'Notes'); $this->outputString("