Don't show devices that have visible set to 0

This commit is contained in:
Starbeamrainbowlabs 2020-05-01 23:34:34 +01:00
parent 5f8ea064b7
commit 0b19464678
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 7 additions and 2 deletions

View file

@ -11,6 +11,7 @@ This is the changelog for the air quality web interface and its associated HTTP
## v0.13.5 ## v0.13.5
- Disable the tour, as it's now causing a crash on startup :-( - 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 ## v0.13.4
- [API] Fix crash in `list-devices-near` action - [API] Fix crash in `list-devices-near` action

View file

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