Zakladna migracia na viacej senzorov

This commit is contained in:
2022-10-28 15:16:05 +02:00
parent 997aa81ff9
commit 5e521583af
12 changed files with 128091 additions and 20872 deletions

View File

@@ -21,6 +21,10 @@ class StatisticsController extends Controller
$enddate = $request->input('enddate',NULL);
$range = $request->input('range',NULL);
$host = $request->input('host','balkon');
$model = $request->input('model','bme280');
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
if (!in_array($type,$types)) $type = $types[0];
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
@@ -35,7 +39,7 @@ class StatisticsController extends Controller
}
}
$q = sprintf("select time,min(value),max(value),mean(value),last(value) from bme280_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s);",$host,$type,$startdate,$enddate,$range);
$q = sprintf("select time,min(value),max(value),mean(value),last(value) from %s_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s);",$model,$host,$type,$startdate,$enddate,$range);
\Debugbar::info($q);
$result = \InfluxDB::query($q);
$points = $result->getPoints();