Little Fixes
This commit is contained in:
parent
14a33b83d0
commit
d013788249
@ -15,13 +15,14 @@ class RoomsApi extends ApiController{
|
|||||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $roomData) {
|
foreach ($roomsData as $roomKey => $roomData) {
|
||||||
if ($roomData['device_count'] <= 0) continue;
|
if ($roomData['device_count'] != 0){
|
||||||
$response[] = [
|
$response[] = [
|
||||||
'room_id' => $roomData['room_id'],
|
'room_id' => $roomData['room_id'],
|
||||||
'name' => $roomData['name'],
|
'name' => $roomData['name'],
|
||||||
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->response($response);
|
$this->response($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@ class RoomManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function getAllRooms () {
|
static function getAllRooms () {
|
||||||
|
//TODO: ignore Widgets withoud data
|
||||||
$allRoom = Db::loadAll ("SELECT rooms.*, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id");
|
$allRoom = Db::loadAll ("SELECT rooms.*, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id");
|
||||||
return $allRoom;
|
return $allRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getRoomsDefault () {
|
static function getRoomsDefault () {
|
||||||
|
//TODO: ignore Widgets withoud data
|
||||||
$allRoom = Db::loadAll ("SELECT rooms.room_id, rooms.name, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id;");
|
$allRoom = Db::loadAll ("SELECT rooms.room_id, rooms.name, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id;");
|
||||||
return $allRoom;
|
return $allRoom;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user