From f88a1c5feac25f5fd3790fada9a09ce8a2fc7dc5 Mon Sep 17 00:00:00 2001 From: JakubAndrysek Date: Sun, 19 Dec 2021 11:57:55 +0100 Subject: [PATCH] Fix database request limit --- .idea/intellij-latte/xmlSources/Latte.dtd | 2 +- .idea/intellij-latte/xmlSources/Latte.xml | 58 +++++++++++---- .idea/workspace.xml | 86 ++++++++++++++++------ app/CoreModule/Model/ThisSensorManager.php | 9 ++- 4 files changed, 113 insertions(+), 42 deletions(-) diff --git a/.idea/intellij-latte/xmlSources/Latte.dtd b/.idea/intellij-latte/xmlSources/Latte.dtd index ab659787..0cf3a95a 100644 --- a/.idea/intellij-latte/xmlSources/Latte.dtd +++ b/.idea/intellij-latte/xmlSources/Latte.dtd @@ -8,7 +8,7 @@ - + diff --git a/.idea/intellij-latte/xmlSources/Latte.xml b/.idea/intellij-latte/xmlSources/Latte.xml index 29502ee9..0bfceaf8 100644 --- a/.idea/intellij-latte/xmlSources/Latte.xml +++ b/.idea/intellij-latte/xmlSources/Latte.xml @@ -12,7 +12,7 @@ - + @@ -182,6 +182,11 @@ + + + + + @@ -197,6 +202,7 @@ + @@ -209,6 +215,7 @@ + @@ -220,25 +227,25 @@ - - - + + + - - - - - - - + + + + + + + - + @@ -247,18 +254,37 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 87e2b003..04de3220 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,24 +2,12 @@ - - - + + - - - - - - - - - - - - - - + + + - - + + + + + + + + + + + + + - - + + @@ -145,7 +144,7 @@ - + @@ -193,6 +192,9 @@ + + + 1609201367814 @@ -374,6 +376,46 @@ 282 diff --git a/app/CoreModule/Model/ThisSensorManager.php b/app/CoreModule/Model/ThisSensorManager.php index d25deda2..5221482d 100755 --- a/app/CoreModule/Model/ThisSensorManager.php +++ b/app/CoreModule/Model/ThisSensorManager.php @@ -86,13 +86,16 @@ public function getAllEvents($sNumber, $from="2000-01-01 00:00:00" , $to="2100-0 public function sensorHasData($sNumber): bool { - return boolval($this->database->table("A".$sNumber)->fetch()); + return boolval($this->database->table("A".$sNumber)->limit(1)->fetch()); } public function getPreviousEvent($sNumber, $events) { - $previous = array_key_first($events)-1; - return $this->database->table("A".$sNumber)->where("id =?",$previous)->fetch(); + if(!$events) { + return false; + } + $previous = array_key_first($events)-1; + return $this->database->table("A".$sNumber)->where("id =?",$previous)->limit(1)->fetch(); }