api/device-info: drastically optimise by removing a redundant JOIN

....why we didn't remove it before, I have no idea.
This commit is contained in:
Starbeamrainbowlabs 2021-01-30 21:33:28 +00:00
parent 5b724a9766
commit 3dc7b58e6e
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 3 additions and 7 deletions

View file

@ -11,7 +11,10 @@ This is the changelog for the air quality web interface and its associated HTTP
## v0.14
- Remove the heatmap background overlay :-(
- Colour device markers based on the latest reading
- [API] Optimise `list-reading-types` action, which necessitated a database schema update and the removal of the `count` property on returned objects
- [API] Drastically optimise `device-info` by removing a redundant JOIN
## v0.13.6

View file

@ -108,11 +108,6 @@ class MariaDBDeviceRepository implements IDeviceRepository {
$s = $this->get_static;
$o = $this->get_static_extra;
$data_repo_class = MariaDBMeasurementDataRepository::class;
$data_repo_table_meta = $o($data_repo_class, "table_name_metadata");
$data_repo_col_datetime = "$data_repo_table_meta.{$o($data_repo_class, "column_metadata_datetime")}";
$data_repo_col_device_id = "$data_repo_table_meta.{$o($data_repo_class, "column_metadata_device_id")}";
$query_result = $this->database->query(
"SELECT
{$s("table_name")}.{$s("column_device_id")} AS id,
@ -125,8 +120,6 @@ class MariaDBDeviceRepository implements IDeviceRepository {
FROM {$s("table_name")}
JOIN {$s("table_name_type")} ON
{$s("table_name")}.{$s("column_device_type")} = {$s("table_name_type")}.{$s("column_type_id")}
JOIN $data_repo_table_meta ON
$data_repo_col_device_id = {$s("table_name")}.{$s("column_device_id")}
WHERE {$s("table_name")}.{$s("column_device_id")} = :device_id
AND {$s("table_name")}.{$s("column_visible")} != 0;", [
"device_id" => $device_id