From 3dc7b58e6e441f0595c8847b3d96f4fe28251499 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 30 Jan 2021 21:33:28 +0000 Subject: [PATCH] api/device-info: drastically optimise by removing a redundant JOIN ....why we didn't remove it before, I have no idea. --- Changelog.md | 3 +++ logic/Repositories/MariaDBDeviceRepository.php | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4a839d6..1b9d89c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/logic/Repositories/MariaDBDeviceRepository.php b/logic/Repositories/MariaDBDeviceRepository.php index 28628a8..f89fb4e 100644 --- a/logic/Repositories/MariaDBDeviceRepository.php +++ b/logic/Repositories/MariaDBDeviceRepository.php @@ -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