Fix measurement data query (I think)

This commit is contained in:
Starbeamrainbowlabs 2019-01-15 17:05:21 +00:00
parent 9f6bea64d4
commit 102bd13864
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -12,7 +12,7 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
public static $column_values_id = "id";
public static $column_values_reading_id = "reading_id";
public static $column_values_value = "value";
public static $column_values_reading_value_types_id = "reading_value_types_id";
public static $column_values_reading_type = "reading_value_types_id";
public static $column_metadata_id = "id";
public static $column_metadata_storedon = "storedon";
@ -67,7 +67,9 @@ class MariaDBMeasurementDataRepository implements IMeasurementDataRepository {
WHERE COALESCE(
{$s("table_name_metadata")}.{$s("column_metadata_recordedon")},
{$s("table_name_metadata")}.{$s("column_metadata_storedon")}
) = :datetime", [
) = :datetime AND
{$s("table_name_values")}.{$s("column_values_reading_type")} = :reading_type
", [
// The database likes strings, not PHP DateTime() instances
"datetime" => $datetime->format(\DateTime::ISO8601),
"reading_type" => $reading_type