Skip to content

Commit

Permalink
Fix test flakiness.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jul 27, 2022
1 parent b648424 commit b7b2cc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/Faultcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function fetchStatus()
SELECT COUNT(DISTINCT results.iddevices) as total FROM
(SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand Down Expand Up @@ -141,7 +141,7 @@ public function fetchStatus()
SELECT results.winning_opinion, COUNT(*) AS total FROM
(SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand Down Expand Up @@ -172,7 +172,7 @@ public function fetchStatus()
$result['list_splits'] = DB::select("
SELECT
d.iddevices,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS top_crowd_opinion,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS top_crowd_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count,
Expand Down Expand Up @@ -203,7 +203,7 @@ public function updateDevices()
DB::statement("CREATE TEMPORARY TABLE IF NOT EXISTS `devices_faults_temporary` AS
SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand Down
8 changes: 4 additions & 4 deletions app/Mobifix.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function fetchStatus()
SELECT COUNT(DISTINCT results.iddevices) as total FROM
(SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand All @@ -117,7 +117,7 @@ public function fetchStatus()
SELECT results.winning_opinion, COUNT(*) AS total FROM
(SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand All @@ -141,7 +141,7 @@ public function fetchStatus()
$result['list_splits'] = DB::select("
SELECT
d.iddevices,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS top_crowd_opinion,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS top_crowd_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count,
Expand Down Expand Up @@ -172,7 +172,7 @@ public function updateDevices()
DB::statement("CREATE TEMPORARY TABLE IF NOT EXISTS `devices_faults_mobiles_temporary` AS
SELECT
o.iddevices,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC LIMIT 1) AS winning_opinion,
(SELECT o1.fault_type FROM devices_faults_mobiles_opinions o1 WHERE o1.iddevices = o.iddevices GROUP BY o1.fault_type ORDER BY COUNT(o1.fault_type) DESC, o1.fault_type ASC LIMIT 1) AS winning_opinion,
ROUND((SELECT COUNT(o2.fault_type) as top_crowd_opinion_count FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices GROUP BY o2.fault_type ORDER BY top_crowd_opinion_count DESC LIMIT 1) /
(SELECT COUNT(o2.fault_type) as all_votes FROM devices_faults_mobiles_opinions o2 WHERE o2.iddevices = o.iddevices) * 100) AS top_crowd_opinion_percentage,
COUNT(o.fault_type) AS all_crowd_opinions_count
Expand Down

0 comments on commit b7b2cc0

Please sign in to comment.