From 6e294377f21b9bb7ce0fba88a19a7c89dba88693 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Sat, 17 Aug 2024 07:25:09 -0400 Subject: [PATCH] Fixed #413 - Comparison counts sometimes decrease when switching from global/all to something more specific --- api/thermostat.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/api/thermostat.php b/api/thermostat.php index 88d31c7..a8d0faa 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -507,23 +507,16 @@ class thermostat extends cora\crud { $memory_per_thermostat = 0.0054; // mb $limit_start = 0; - $limit_count = round($memory_limit / $memory_per_thermostat); + $limit_count = (int) round($memory_limit / $memory_per_thermostat); /** * Selecting lots of rows can eventually run PHP out of memory, so chunk * this up into several queries to avoid that. */ do { - $result = $this->database->query(' - select - thermostat_id, - profile - from - thermostat - where ' . - implode(' and ', $where) . ' - limit ' . $limit_start . ',' . $limit_count . ' - '); + $result = $this->database->query( + 'select thermostat_id, profile from thermostat where ' . implode(' and ', $where) . ' limit ' . $limit_start . ',' . $limit_count . '' + ); // Get all the scores from the other thermostats while($other_thermostat = $result->fetch_assoc()) {