mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-22 06:23:01 +00:00
Add last_seen to device-info. For 36
This commit is contained in:
parent
5efaab3f67
commit
d5df81eed1
2 changed files with 15 additions and 6 deletions
|
@ -7,7 +7,7 @@ This is the changelog for the air quality web interface and its associated HTTP
|
|||
|
||||
## v0.12-dev
|
||||
- [API] Improve accuracy of `distance_calc` for the `list-devices-near` action by using _Haversine's Formula_.
|
||||
- [API] Added new `last_seen` property to the `list-devices` action.
|
||||
- [API] Added new `last_seen` property to the `list-devices` and `device-info` actions.
|
||||
|
||||
## v0.11.1 - 22nd June 2019
|
||||
- Drastically improve the performance of the backend SQL queries that power the heatmap and device graphs by over 35x in some cases!
|
||||
|
|
|
@ -74,10 +74,10 @@ class MariaDBDeviceRepository implements IDeviceRepository {
|
|||
$s = $this->get_static;
|
||||
$o = $this->get_static_extra;
|
||||
|
||||
$data_repo_name = MariaDBMeasurementDataRepository::class;
|
||||
$data_repo_table_meta = $o($data_repo_name, "table_name_metadata");
|
||||
$data_repo_col_datetime = "$data_repo_table_meta.{$o($data_repo_name, "column_metadata_datetime")}";
|
||||
$data_repo_col_device_id = "$data_repo_table_meta.{$o($data_repo_name, "column_metadata_device_id")}";
|
||||
$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")}";
|
||||
|
||||
$sql = "SELECT
|
||||
{$s("table_name")}.{$s("column_device_id")} AS id,
|
||||
|
@ -104,6 +104,12 @@ class MariaDBDeviceRepository implements IDeviceRepository {
|
|||
|
||||
public function get_device_info_ext($device_id) {
|
||||
$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
|
||||
|
@ -112,10 +118,13 @@ class MariaDBDeviceRepository implements IDeviceRepository {
|
|||
{$s("table_name")}.{$s("column_lat")} AS latitude,
|
||||
{$s("table_name")}.{$s("column_long")} AS longitude,
|
||||
{$s("table_name")}.{$s("column_altitude")} AS altitude,
|
||||
{$s("table_name_type")}.*
|
||||
{$s("table_name_type")}.*,
|
||||
MAX($data_repo_col_datetime) AS last_seen
|
||||
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;", [
|
||||
"device_id" => $device_id
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue