commit 6b97ff5c072fc101585420922fa1e8b9359668d4 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Jan 15 09:18:26 2013 +0100
Don't expect optional fields in details documents.
Fixes #7885 and proactively fixes similar bugs which just didn't show up yet. --- js/models/relay.js | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/js/models/relay.js b/js/models/relay.js index c385f95..e1e74fb 100644 --- a/js/models/relay.js +++ b/js/models/relay.js @@ -135,23 +135,22 @@ define([ if (data.relays.length >= 1) { var relay = data.relays[0]; //console.log(data); - var bw = relay.advertised_bandwidth; - relay.bandwidth = bw; + relay.bandwidth = relay.advertised_bandwidth ? relay.advertised_bandwidth : null; + relay.bandwidth_hr = relay.advertised_bandwidth ? hrBandwidth(relay.advertised_bandwidth) : null; relay.family = relay.family ? relay.family : null; - relay.bandwidth_hr = hrBandwidth(bw); relay.or_address = relay.or_addresses ? relay.or_addresses[0].split(":")[0] : null; relay.or_port = relay.or_addresses ? relay.or_addresses[0].split(":")[1] : 0; relay.dir_port = relay.dir_address ? relay.dir_address.split(":")[1] : 0; relay.country = relay.country ? relay.country.toLowerCase() : null; relay.countryname = relay.country ? CountryCodes[relay.country] : null; relay.uptime = relay.last_restarted ? model.parsedate(relay.last_restarted) : null; - relay.uptime_hr = relay.uptime ? relay.uptime.hr : null; - relay.as_no = relay.as_number; - relay.as_name = relay.as_name; - model.set({badexit: false}); + relay.uptime_hr = relay.last_restarted ? relay.uptime.hr : null; + relay.uptime_hrfull = relay.last_restarted ? relay.uptime.hrfull : null; //console.log(relay.uptime.hrfull); - relay.uptime_hrfull = relay.uptime ? relay.uptime.hrfull : null; - relay.uptime = relay.uptime ? relay.uptime.millisecs : null; + relay.uptime = relay.last_restarted ? relay.uptime.millisecs : null; + relay.as_no = relay.as_number ? relay.as_number : null; + relay.as_name = relay.as_name ? relay.as_name : null; + model.set({badexit: false}); var size = ['16x16', '14x16', '8x16']; relay.flags = model.parseflags(relay.flags, size); model.set(relay, options);