mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-21 06:22:59 +00:00
Bugfix new device-recent-data action
This commit is contained in:
parent
dba984340d
commit
009e2e4b72
2 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,11 @@ Action | Meaning
|
||||||
[`device-data`](#device-data) | Gets data by device given a start and end time.
|
[`device-data`](#device-data) | Gets data by device given a start and end time.
|
||||||
[`changelog`](#changelog) | Gets the changelog as a fragment of HTML.
|
[`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
|
## version
|
||||||
> Returns the version of the application.
|
> Returns the version of the application.
|
||||||
|
|
|
@ -166,13 +166,13 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
|
||||||
$s = $this->get_static;
|
$s = $this->get_static;
|
||||||
return $this->database->query(
|
return $this->database->query(
|
||||||
"SELECT
|
"SELECT
|
||||||
AVG({$s("table_name_values")}.{$s("column_values_value")}) AS {$s("column_values_value")},
|
{$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_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_recordedon")},
|
||||||
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
|
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
|
||||||
)) AS datetime
|
) AS datetime
|
||||||
FROM {$s("table_name_values")}
|
FROM {$s("table_name_values")}
|
||||||
JOIN {$s("table_name_metadata")} ON
|
JOIN {$s("table_name_metadata")} ON
|
||||||
{$s("table_name_metadata")}.{$s("column_metadata_id")} = {$s("table_name_values")}.{$s("column_values_reading_id")}
|
{$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(
|
ORDER BY COALESCE(
|
||||||
{$s("table_name_metadata")}.{$s("column_metadata_recordedon")},
|
{$s("table_name_metadata")}.{$s("column_metadata_recordedon")},
|
||||||
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
|
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
|
||||||
)
|
) DESC
|
||||||
LIMIT :count;", [
|
LIMIT :count;", [
|
||||||
"device_id" => $device_id,
|
"device_id" => $device_id,
|
||||||
"reading_type" => $type_id,
|
"reading_type" => $type_id,
|
||||||
|
|
Loading…
Reference in a new issue