- viac senzorov, oprava chyb ked nevracia hodnotu controller
This commit is contained in:
@@ -32,13 +32,15 @@ class MeasurementController extends Controller
|
||||
if ($enddate == NULL || $enddate == '') $enddate = "now()";
|
||||
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
|
||||
|
||||
$q = sprintf("select time,value from %s_value where host='%s' and type='%s' and time >= %s and time <= %s",$model,$host,$type,$startdate,$enddate);
|
||||
$q = sprintf("select time,mean(value) as v from %s_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s) fill(linear)",$model,$host,$type,$startdate,$enddate,'5m');
|
||||
\Debugbar::info($q);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
$a = [];
|
||||
foreach ($points as $p) {
|
||||
$a[] = [ Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC'), $p["value"]];
|
||||
if (!isset($p["v"])) continue;
|
||||
$a[] = [ $p["time"], $p["v"]];
|
||||
// $a[] = [ Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC'), $p["v"]];
|
||||
}
|
||||
|
||||
return response()->json($a);
|
||||
|
||||
Reference in New Issue
Block a user