mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-25 06:53:00 +00:00
[server] Bugfix: Updatee device-data action t use DB structure
This commit is contained in:
parent
69a581094a
commit
519e85b66a
3 changed files with 7 additions and 5 deletions
|
@ -69,7 +69,9 @@ class DeviceData implements IAction {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->type_repo->is_valid_type($_GET["reading-type"])) {
|
$reading_type_id = $this->type_repo->get_id($_GET["reading-type"]);
|
||||||
|
|
||||||
|
if($reading_type_id == null) {
|
||||||
$this->sender->send_error_plain(
|
$this->sender->send_error_plain(
|
||||||
400, "Error: That reading type is invalid.", [
|
400, "Error: That reading type is invalid.", [
|
||||||
[ "x-time-taken", PerfFormatter::format_perf_data($start_time, $start_handle, null) ]
|
[ "x-time-taken", PerfFormatter::format_perf_data($start_time, $start_handle, null) ]
|
||||||
|
@ -81,7 +83,7 @@ class DeviceData implements IAction {
|
||||||
// 2: Pull data from database
|
// 2: Pull data from database
|
||||||
$data = $this->measurement_repo->get_readings_by_device(
|
$data = $this->measurement_repo->get_readings_by_device(
|
||||||
intval($_GET["device-id"]),
|
intval($_GET["device-id"]),
|
||||||
$_GET["reading-type"],
|
$reading_type_id,
|
||||||
new \DateTime($_GET["start"]),
|
new \DateTime($_GET["start"]),
|
||||||
new \DateTime($_GET["end"]),
|
new \DateTime($_GET["end"]),
|
||||||
!empty($_GET["average-seconds"]) ? intval($_GET["average-seconds"]) : 1
|
!empty($_GET["average-seconds"]) ? intval($_GET["average-seconds"]) : 1
|
||||||
|
|
|
@ -13,9 +13,9 @@ interface IMeasurementTypeRepository {
|
||||||
/**
|
/**
|
||||||
* Get the id associated with the given short description.
|
* Get the id associated with the given short description.
|
||||||
* @param string $short_descr The short description to convert.
|
* @param string $short_descr The short description to convert.
|
||||||
* @return int The id associated with the specified short description.
|
* @return int|null The id associated with the specified short description.
|
||||||
*/
|
*/
|
||||||
public function get_id(string $short_descr) : int;
|
public function get_id(string $short_descr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the friendly name for the specified type name.
|
* Gets the friendly name for the specified type name.
|
||||||
|
|
|
@ -41,7 +41,7 @@ class MariaDBMeasurementTypeRepository implements IMeasurementTypeRepository {
|
||||||
)->fetchColumn());
|
)->fetchColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_id(string $short_descr) : int {
|
public function get_id(string $short_descr) {
|
||||||
$s = $this->get_static;
|
$s = $this->get_static;
|
||||||
|
|
||||||
$result = $this->database->query(
|
$result = $this->database->query(
|
||||||
|
|
Loading…
Reference in a new issue