[server] Bugfix: Updatee device-data action t use DB structure

pull/26/head
Starbeamrainbowlabs 4 years ago
parent 69a581094a
commit 519e85b66a
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 6
      logic/Actions/DeviceData.php
  2. 4
      logic/Repositories/IMeasurementTypeRepository.php
  3. 2
      logic/Repositories/MariaDBMeasurementTypeRepository.php

@ -69,7 +69,9 @@ class DeviceData implements IAction {
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(
400, "Error: That reading type is invalid.", [
[ "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
$data = $this->measurement_repo->get_readings_by_device(
intval($_GET["device-id"]),
$_GET["reading-type"],
$reading_type_id,
new \DateTime($_GET["start"]),
new \DateTime($_GET["end"]),
!empty($_GET["average-seconds"]) ? intval($_GET["average-seconds"]) : 1

@ -13,9 +13,9 @@ interface IMeasurementTypeRepository {
/**
* Get the id associated with the given short description.
* @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.

@ -41,7 +41,7 @@ class MariaDBMeasurementTypeRepository implements IMeasurementTypeRepository {
)->fetchColumn());
}
public function get_id(string $short_descr) : int {
public function get_id(string $short_descr) {
$s = $this->get_static;
$result = $this->database->query(

Loading…
Cancel
Save