Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latitude and longitude on devices/device fetch #8504

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion html/includes/api_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function list_devices()
$param[] = $_SESSION['user_id'];
}
$devices = array();
$dev_query = "SELECT $select FROM `devices` AS d $join WHERE $sql GROUP BY d.`hostname` ORDER BY $order";
$dev_query = "SELECT dev.*, lat, lng FROM (SELECT $select FROM `devices` AS d $join WHERE $sql GROUP BY d.`hostname` ORDER BY $order) dev LEFT JOIN locations ON locations.location=dev.location";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this line back to how it was and use this patch instead:

https://p.libren.ms/view/raw/d23ae0fb

foreach (dbFetchRows($dev_query, $param) as $device) {
$host_id = get_vm_parent_id($device);
$device['ip'] = inet6_ntop($device['ip']);
Expand Down
2 changes: 1 addition & 1 deletion includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function device_by_id_cache($device_id, $refresh = false)
if (!$refresh && isset($cache['devices']['id'][$device_id]) && is_array($cache['devices']['id'][$device_id])) {
$device = $cache['devices']['id'][$device_id];
} else {
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
$device = dbFetchRow("SELECT `devices`.*, `lat`, `lng` FROM `devices` LEFT JOIN locations ON `devices`.`location`=`locations`.`location` WHERE `device_id` = ?", array($device_id));
$device['attribs'] = get_dev_attribs($device['device_id']);
load_os($device);

Expand Down