fontawesome pridane, zobrazenie intervalu
This commit is contained in:
@@ -18,15 +18,24 @@ class MeasurementController extends Controller
|
||||
$types = ['temperature','humidity','pressure'];
|
||||
|
||||
$type = $request->input('type', $types[0]);
|
||||
$startdate = $request->input('startdate',NULL);
|
||||
$enddate = $request->input('enddate',NULL);
|
||||
if (!in_array($type,$types)) $type = $types[0];
|
||||
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
|
||||
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
|
||||
|
||||
$q = sprintf("select time,value from bme280_value where host='balkon' and type='%s' and time > now()-1d",$type);
|
||||
if ($enddate == NULL || $enddate == '') $enddate = "now()";
|
||||
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
|
||||
|
||||
$q = sprintf("select time,value from bme280_value where host='balkon' and type='%s' and time >= %s and time <= %s",$type,$startdate,$enddate);
|
||||
\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"]];
|
||||
}
|
||||
|
||||
return response()->json($a);
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user