[tor-commits] [metrics-web/release] Use "as" in place of "as_number" field for RS

karsten at torproject.org karsten at torproject.org
Wed Sep 26 15:20:35 UTC 2018


commit 9e49336e2cc3c4f94824157aa19754598e2123b5
Author: Iain R. Learmonth <irl at fsfe.org>
Date:   Wed Sep 12 10:22:11 2018 +0100

    Use "as" in place of "as_number" field for RS
    
    Fixes: #27652
---
 src/main/resources/web/js/rs/collections/aggregates.js  | 14 +++++++-------
 src/main/resources/web/js/rs/models/relay.js            |  2 +-
 src/main/resources/web/templates/rs/details/router.html |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/resources/web/js/rs/collections/aggregates.js b/src/main/resources/web/js/rs/collections/aggregates.js
index 75c5e22..bbf5a45 100644
--- a/src/main/resources/web/js/rs/collections/aggregates.js
+++ b/src/main/resources/web/js/rs/collections/aggregates.js
@@ -7,7 +7,7 @@ define([
 ], function($, _, Backbone, aggregateModel){
   var aggregatesCollection = Backbone.Collection.extend({
     model: aggregateModel,
-    baseurl: 'https://onionoo.torproject.org/details?running=true&type=relay&fields=country,guard_probability,middle_probability,exit_probability,consensus_weight,consensus_weight_fraction,advertised_bandwidth,flags,as_number,as_name,measured,version',
+    baseurl: 'https://onionoo.torproject.org/details?running=true&type=relay&fields=country,guard_probability,middle_probability,exit_probability,consensus_weight,consensus_weight_fraction,advertised_bandwidth,flags,as,as_name,measured,version',
     url: '',
     aType: 'cc',
     lookup: function(options) {
@@ -32,8 +32,8 @@ define([
              This code will never be assigned for use with ISO 3166-1 and is "user-assigned".
              Fun fact: UN/LOCODE assigns XZ to represent installations in international waters. */
           relay.country = ((typeof relay.country) == "undefined") ? "xz" : relay.country;
-          relay.as_number = ((typeof relay.as_number) == "undefined") ? "AS0" : relay.as_number;
-          if (relay.as_number == "AS0") relay.as_name = "Unknown";
+          relay.as = ((typeof relay.as) == "undefined") ? "AS0" : relay.as;
+          if (relay.as == "AS0") relay.as_name = "Unknown";
 
           var ccAggregate = false;
           var asAggregate = false;
@@ -45,13 +45,13 @@ define([
             aggregateKey = relay.country;
             ccAggregate = true;
           } else if (collection.aType == "as") {
-            aggregateKey = relay.as_number;
+            aggregateKey = relay.as;
             asAggregate = true;
           } else if (collection.aType == "version") {
             aggregateKey = relay.version.split(".").slice(0, 3).join(".") + ".";
             versionAggregate = true;
           } else {
-            aggregateKey = relay.country + "/" + relay.as_number;
+            aggregateKey = relay.country + "/" + relay.as;
             ccAggregate = asAggregate = true;
           }
 
@@ -63,7 +63,7 @@ define([
               aggregates[aggregateKey].country = new Set();
             }
             if (asAggregate) {
-              aggregates[aggregateKey].as = relay.as_number;
+              aggregates[aggregateKey].as = relay.as;
             } else {
               aggregates[aggregateKey].as = new Set();
             }
@@ -77,7 +77,7 @@ define([
             if (relay.country !== "xz") aggregates[aggregateKey].country.add(relay.country);
           }
           if (!asAggregate) {
-            if (relay.as_number !== "AS0") aggregates[aggregateKey].as.add(relay.as_number);
+            if (relay.as !== "AS0") aggregates[aggregateKey].as.add(relay.as);
           }
           aggregates[aggregateKey].relays++;
           if ((typeof relay.guard_probability) !== "undefined") aggregates[aggregateKey].guard_probability += relay.guard_probability;
diff --git a/src/main/resources/web/js/rs/models/relay.js b/src/main/resources/web/js/rs/models/relay.js
index b5a6b8e..eeb0569 100644
--- a/src/main/resources/web/js/rs/models/relay.js
+++ b/src/main/resources/web/js/rs/models/relay.js
@@ -234,7 +234,7 @@ define([
                     relay.uptime = relay.last_restarted ? relay.uptime.millisecs : null;
                     relay.last_restarted = relay.last_restarted ? relay.last_restarted : null;
                     relay.downtime = relay.last_seen ? model.parsedate(relay.last_seen).hrfull : null;
-                    relay.as_number = relay.as_number ? relay.as_number : null;
+                    relay.as = relay.as ? relay.as : null;
                     relay.as_name = relay.as_name ? relay.as_name : null;
                     relay.transports = relay.transports ? relay.transports : null;
                     relay.fingerprint = relay.hashed_fingerprint ? relay.hashed_fingerprint : relay.fingerprint;
diff --git a/src/main/resources/web/templates/rs/details/router.html b/src/main/resources/web/templates/rs/details/router.html
index c746269..d7596ca 100644
--- a/src/main/resources/web/templates/rs/details/router.html
+++ b/src/main/resources/web/templates/rs/details/router.html
@@ -153,7 +153,7 @@ should update it as soon as possible.</div>
     <dd><% if (relay.get('country')) { %><img class="inline country" title="<%= relay.get('countryname') %>" alt="" src="/images/cc/<%= relay.get('country') %>.png"/> <a href="#search/country:<%= relay.get('country') %>"><%= relay.get('countryname') %></a> (<a href="#search/country:<%= relay.get('country') %>%20flag:exit"><img src="/images/flags/exit.png" title="All exits in <%= relay.get('countryname') %>"></a>)<% } else { %>Unknown<% } %></dd>
 
     <dt><span class="tip" title="Autonomous System Number">AS Number</span></dt>
-    <dd><% if (relay.get('as_number') !== null) { %><a href="#search/as:<%= relay.get('as_number') %>"><%= _.escape(relay.get('as_number')) %></a><% } else { %>unknown<% }; %></dd>
+    <dd><% if (relay.get('as') !== null) { %><a href="#search/as:<%= relay.get('as') %>"><%= _.escape(relay.get('as')) %></a><% } else { %>unknown<% }; %></dd>
 
     <dt><span class="tip" title="Autonomous System Name">AS Name</span></dt>
     <dd><%= relay.get('as_name') ? _.escape(relay.get('as_name')) : "unknown" %></dd>





More information about the tor-commits mailing list