Browse Source

Don't show devices that have visible set to 0

pull/65/head
Starbeamrainbowlabs 2 years ago
parent
commit
0b19464678
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 1
      Changelog.md
  2. 8
      logic/Repositories/MariaDBDeviceRepository.php

1
Changelog.md

@ -11,6 +11,7 @@ This is the changelog for the air quality web interface and its associated HTTP @@ -11,6 +11,7 @@ This is the changelog for the air quality web interface and its associated HTTP
## v0.13.5
- Disable the tour, as it's now causing a crash on startup :-(
- [API] Don't return devices in the device lists that have the `visible` flag in the database set to `0`
## v0.13.4
- [API] Fix crash in `list-devices-near` action

8
logic/Repositories/MariaDBDeviceRepository.php

@ -22,6 +22,7 @@ class MariaDBDeviceRepository implements IDeviceRepository { @@ -22,6 +22,7 @@ class MariaDBDeviceRepository implements IDeviceRepository {
public static $column_point = "lat_lon";
public static $column_altitude = "device_altitude";
public static $column_last_seen = "last_seen";
public static $column_visible = "visible";
public static $table_name_type = "device_types";
public static $column_type_id = "device_type";
@ -90,7 +91,8 @@ class MariaDBDeviceRepository implements IDeviceRepository { @@ -90,7 +91,8 @@ class MariaDBDeviceRepository implements IDeviceRepository {
{$s("table_name")}.{$s("column_last_seen")} AS last_seen
FROM {$s("table_name")}
JOIN $data_repo_table_meta ON
$data_repo_col_device_id = {$s("table_name")}.{$s("column_device_id")}";
$data_repo_col_device_id = {$s("table_name")}.{$s("column_device_id")}
WHERE {$s("table_name")}.{$s("column_visible")} != 0";
if($only_with_location)
$sql .= "\nWHERE
@ -126,7 +128,8 @@ class MariaDBDeviceRepository implements IDeviceRepository { @@ -126,7 +128,8 @@ class MariaDBDeviceRepository implements IDeviceRepository {
{$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;", [
WHERE {$s("table_name")}.{$s("column_device_id")} = :device_id
AND {$s("table_name")}.{$s("column_visible")} != 0;", [
"device_id" => $device_id
]
)->fetch(); // gets the next row from the query
@ -167,6 +170,7 @@ class MariaDBDeviceRepository implements IDeviceRepository { @@ -167,6 +170,7 @@ class MariaDBDeviceRepository implements IDeviceRepository {
JOIN $data_repo_table_meta ON
$data_repo_col_device_id = {$s("table_name")}.{$s("column_device_id")}
WHERE {$s("table_name")}.{$s("column_point")} IS NOT NULL
AND {$s("table_name")}.{$s("column_visible")} != 0
ORDER BY ST_DISTANCE_SPHERE(POINT(:latitude_again, :longitude_again), {$s("table_name")}.{$s("column_point")})
LIMIT :count;", [
"latitude" => $lat,

Loading…
Cancel
Save