mirror of
https://github.com/status-im/consul.git
synced 2025-01-26 21:51:39 +00:00
Merge pull request #2251 from hashicorp/b-tomography-js-error
Fixes JS exception when there are no coordinates present.
This commit is contained in:
commit
3a21d4b48d
File diff suppressed because one or more lines are too long
@ -311,11 +311,18 @@ App.NodesShowRoute = App.BaseRoute.extend({
|
||||
var n = distances.length;
|
||||
var halfN = Math.floor(n / 2);
|
||||
var median;
|
||||
if (n % 2) {
|
||||
// odd
|
||||
median = distances[halfN].distance;
|
||||
|
||||
if (n > 0) {
|
||||
if (n % 2) {
|
||||
// odd
|
||||
median = distances[halfN].distance;
|
||||
} else {
|
||||
median = (distances[halfN - 1].distance + distances[halfN].distance) / 2;
|
||||
}
|
||||
} else {
|
||||
median = (distances[halfN - 1].distance + distances[halfN].distance) / 2;
|
||||
median = 0;
|
||||
min = 0;
|
||||
max = 0;
|
||||
}
|
||||
|
||||
// Return a promise hash of the node and nodes
|
||||
|
Loading…
x
Reference in New Issue
Block a user