Browse Source

Bugfix new device-recent-data action

pull/35/head
Starbeamrainbowlabs 3 years ago
parent
commit
009e2e4b72
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 6
      docs/05-API-Docs.md
  2. 10
      logic/Repositories/MariaDBMeasurementDataRepository.php

6
docs/05-API-Docs.md

@ -14,7 +14,11 @@ Action | Meaning @@ -14,7 +14,11 @@ Action | Meaning
[`device-data`](#device-data) | Gets data by device given a start and end time.
[`changelog`](#changelog) | Gets the changelog as a fragment of HTML.
These are explained in detail below:
These are explained in detail below. First though, a few notes:
- All dates are in UTC.
- All datetime-type fields support the keyword `now`.
## version
> Returns the version of the application.

10
logic/Repositories/MariaDBMeasurementDataRepository.php

@ -166,13 +166,13 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository { @@ -166,13 +166,13 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
$s = $this->get_static;
return $this->database->query(
"SELECT
AVG({$s("table_name_values")}.{$s("column_values_value")}) AS {$s("column_values_value")},
MIN({$s("table_name_values")}.{$s("column_values_reading_id")}) AS {$s("column_values_reading_id")},
{$s("table_name_values")}.{$s("column_values_value")} AS {$s("column_values_value")},
{$s("table_name_values")}.{$s("column_values_reading_id")} AS {$s("column_values_reading_id")},
MIN(COALESCE(
COALESCE(
{$s("table_name_metadata")}.{$s("column_metadata_recordedon")},
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
)) AS datetime
) AS datetime
FROM {$s("table_name_values")}
JOIN {$s("table_name_metadata")} ON
{$s("table_name_metadata")}.{$s("column_metadata_id")} = {$s("table_name_values")}.{$s("column_values_reading_id")}
@ -182,7 +182,7 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository { @@ -182,7 +182,7 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
ORDER BY COALESCE(
{$s("table_name_metadata")}.{$s("column_metadata_recordedon")},
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
)
) DESC
LIMIT :count;", [
"device_id" => $device_id,
"reading_type" => $type_id,

Loading…
Cancel
Save