Browse Source

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

....why we didn't remove it before, I have no idea.
pull/65/head
Starbeamrainbowlabs 10 months ago
parent
commit
3dc7b58e6e
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
  1. 3
      Changelog.md
  2. 7
      logic/Repositories/MariaDBDeviceRepository.php

3
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

7
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

Loading…
Cancel
Save