Bugfix new device-recent-data action

This commit is contained in:
Starbeamrainbowlabs 2019-06-13 22:10:14 +01:00
parent dba984340d
commit 009e2e4b72
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 10 additions and 6 deletions

View file

@ -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.

View file

@ -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 {
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,