All graph displays now check if the log excists.

Tue, 21 Jan 2020 21:16:26 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 21 Jan 2020 21:16:26 +0100
changeset 601
112c278be803
parent 600
c136dd22f662
child 602
10b61aacb1c1

All graph displays now check if the log excists.

www/getfermentlog.php file | annotate | diff | comparison | revisions
www/getispindellog.php file | annotate | diff | comparison | revisions
--- a/www/getfermentlog.php	Tue Jan 21 11:09:25 2020 +0100
+++ b/www/getfermentlog.php	Tue Jan 21 21:16:26 2020 +0100
@@ -8,12 +8,18 @@
 	$code = "TB0015 Winterbier-2";
 
 $filename = 'log/fermentation/' . $code . '.log';
+if (! file_exists($filename)) {
+        header("Content-type: application/json");
+        echo '{}';
+        exit;
+}
+
+
 /*
  * From Stackoverflow, the fastest way to count the lines in a file.
  */
 $file = new \SplFileObject($filename, 'r');
 $file->seek(PHP_INT_MAX);
-// $file->key() = lines in the file.
 
 define ('MAX_INTERVALS', 10);
 $GRAPH_INTERVAL = array ( 0, 1, 5, 15, 30, 60, 120, 240, 480, 720 );
@@ -27,8 +33,6 @@
 if ($graphstep > MAX_INTERVALS)
 	$graphstep = MAX_INTERVALS;
 
-//echo $code . '.log lines=' . $file->key() . ' interval=' . $GRAPH_INTERVAL[$graphstep] . ' graphstep=' . $graphstep . PHP_EOL;
-
 /*
  * 2014-11-15 18:39,BEER,PRIMARY,20.312,19.750,-1.500,20.5,18.6,18.8,35,12345,0,67890,Whatsup
  *          |         |     |      |      |      |      |    |    |   |   |   |   |      |
@@ -115,4 +119,3 @@
 }
 header("Content-type: application/json");
 echo json_encode($logs);
-//echo $lines . ' lines' . PHP_EOL;
--- a/www/getispindellog.php	Tue Jan 21 11:09:25 2020 +0100
+++ b/www/getispindellog.php	Tue Jan 21 21:16:26 2020 +0100
@@ -8,6 +8,12 @@
 	$code = "TB0091 Kwik";
 
 $filename = 'log/ispindel/' . $code . '.log';
+if (! file_exists($filename)) {
+        header("Content-type: application/json");
+        echo '{}';
+        exit;
+}
+
 
 /*
  * 2014-11-15 18:39:12,TEMPERATURE,PLATO,SG,BATTERY,ANGLE,INVERVAL,UUID
@@ -42,4 +48,3 @@
 }
 header("Content-type: application/json");
 echo json_encode($logs);
-//echo $lines . ' lines' . PHP_EOL;

mercurial