[server] Bugfix: Filter result of device-data action by reading type

This commit is contained in:
Starbeamrainbowlabs 2019-01-20 22:03:06 +00:00
parent 25ab294d1c
commit ee6cf4a86e
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -131,6 +131,8 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
{$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")}
WHERE WHERE
{$s("table_name_metadata")}.{$s("column_metadata_device_id")} = :device_id AND {$s("table_name_metadata")}.{$s("column_metadata_device_id")} = :device_id AND
{$s("table_name_values")}.{$s("column_values_reading_type")} = :reading_type AND
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")}
@ -144,6 +146,7 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
{$s("table_name_metadata")}.{$s("column_metadata_storedon")} {$s("table_name_metadata")}.{$s("column_metadata_storedon")}
)) / :average_seconds);", [ )) / :average_seconds);", [
"device_id" => $device_id, "device_id" => $device_id,
"reading_type" => $reading_type,
"start_datetime" => $start->format(\DateTime::ISO8601), "start_datetime" => $start->format(\DateTime::ISO8601),
"end_datetime" => $end->format(\DateTime::ISO8601), "end_datetime" => $end->format(\DateTime::ISO8601),
"average_seconds" => $average_seconds "average_seconds" => $average_seconds