[tor-commits] [metrics-web/master] Fix underlying data links to stats page.

karsten at torproject.org karsten at torproject.org
Mon Jan 9 17:03:42 UTC 2017


commit c00be5b9d477ea6ddea94f221162edcba27463a7
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Wed Dec 21 20:27:00 2016 +0100

    Fix underlying data links to stats page.
---
 website/etc/metrics.json                           | 48 +++++++++++-----------
 .../org/torproject/metrics/web/MetricServlet.java  | 22 ++--------
 website/web/WEB-INF/graph.jsp                      |  2 +-
 website/web/WEB-INF/link.jsp                       |  2 +-
 website/web/WEB-INF/stats.jsp                      |  9 ++++
 website/web/WEB-INF/table.jsp                      |  2 +-
 6 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/website/etc/metrics.json b/website/etc/metrics.json
index 2173db8..0a6c924 100644
--- a/website/etc/metrics.json
+++ b/website/etc/metrics.json
@@ -10,7 +10,7 @@
       "end"
     ],
     "data": [
-      "servers-data"
+      "servers"
     ]
   },
   {
@@ -25,7 +25,7 @@
       "flag"
     ],
     "data": [
-      "servers-data"
+      "servers"
     ]
   },
   {
@@ -39,7 +39,7 @@
       "end"
     ],
     "data": [
-      "servers-data"
+      "servers"
     ]
   },
   {
@@ -53,7 +53,7 @@
       "end"
     ],
     "data": [
-      "servers-data"
+      "servers"
     ]
   },
   {
@@ -67,7 +67,7 @@
       "end"
     ],
     "data": [
-      "bandwidth-data"
+      "bandwidth"
     ]
   },
   {
@@ -81,7 +81,7 @@
       "end"
     ],
     "data": [
-      "bandwidth-data"
+      "bandwidth"
     ]
   },
   {
@@ -95,7 +95,7 @@
       "end"
     ],
     "data": [
-      "bandwidth-data"
+      "bandwidth"
     ]
   },
   {
@@ -109,7 +109,7 @@
       "end"
     ],
     "data": [
-      "bandwidth-data"
+      "bandwidth"
     ]
   },
   {
@@ -124,7 +124,7 @@
       "p"
     ],
     "data": [
-      "advbwdist-data"
+      "advbwdist"
     ]
   },
   {
@@ -139,7 +139,7 @@
       "n"
     ],
     "data": [
-      "advbwdist-data"
+      "advbwdist"
     ]
   },
   {
@@ -160,7 +160,7 @@
       "events"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -182,7 +182,7 @@
       "${abs} (${rel} %)"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -206,7 +206,7 @@
       "${upturns}"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -221,7 +221,7 @@
       "country"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -243,7 +243,7 @@
       "${abs} (${rel} %)"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -258,7 +258,7 @@
       "transport"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -273,7 +273,7 @@
       "country"
     ],
     "data": [
-      "userstats-combined-data"
+      "userstats-combined"
     ]
   },
   {
@@ -288,7 +288,7 @@
       "version"
     ],
     "data": [
-      "clients-data"
+      "clients"
     ]
   },
   {
@@ -310,7 +310,7 @@
       "filesize"
     ],
     "data": [
-      "torperf-data"
+      "torperf"
     ]
   },
   {
@@ -326,7 +326,7 @@
       "filesize"
     ],
     "data": [
-      "torperf-data"
+      "torperf"
     ]
   },
   {
@@ -340,7 +340,7 @@
       "end"
     ],
     "data": [
-      "connbidirect2-data"
+      "connbidirect2"
     ]
   },
   {
@@ -354,7 +354,7 @@
       "end"
     ],
     "data": [
-      "hidserv-data"
+      "hidserv"
     ]
   },
   {
@@ -368,7 +368,7 @@
       "end"
     ],
     "data": [
-      "hidserv-data"
+      "hidserv"
     ]
   },
   {
@@ -382,7 +382,7 @@
       "end"
     ],
     "data": [
-      "hidserv-data"
+      "hidserv"
     ]
   },
   {
diff --git a/website/src/org/torproject/metrics/web/MetricServlet.java b/website/src/org/torproject/metrics/web/MetricServlet.java
index b643a02..284a3be 100644
--- a/website/src/org/torproject/metrics/web/MetricServlet.java
+++ b/website/src/org/torproject/metrics/web/MetricServlet.java
@@ -35,8 +35,8 @@ public abstract class MetricServlet extends AnyServlet {
   protected Map<String, String[]> tableCellFormats =
       new HashMap<String, String[]>();
 
-  protected Map<String, List<String[]>> data =
-      new HashMap<String, List<String[]>>();
+  protected Map<String, String[]> data =
+      new HashMap<String, String[]>();
 
   protected Map<String, Category> categoriesById =
       new HashMap<String, Category>();
@@ -46,7 +46,6 @@ public abstract class MetricServlet extends AnyServlet {
     super.init();
     this.metrics = ContentProvider.getInstance().getMetricsList();
     Map<String, String> allTypesAndTitles = new HashMap<String, String>();
-    Map<String, String[]> dataIds = new HashMap<String, String[]>();
     for (Metric metric : this.metrics) {
       String id = metric.getId();
       String title = metric.getTitle();
@@ -68,22 +67,7 @@ public abstract class MetricServlet extends AnyServlet {
         this.tableCellFormats.put(id, metric.getTableCellFormats());
       }
       if (metric.getData() != null) {
-        dataIds.put(id, metric.getData());
-      }
-    }
-    for (Set<String> ids : idsByType.values()) {
-      for (String id : ids) {
-        if (dataIds.containsKey(id)) {
-          List<String[]> dataLinksTypesAndTitles =
-              new ArrayList<String[]>();
-          for (String dataId : dataIds.get(id)) {
-            if (allTypesAndTitles.containsKey(dataId)) {
-              dataLinksTypesAndTitles.add(new String[] { dataId + ".html",
-                  allTypesAndTitles.get(dataId) } );
-            }
-          }
-          this.data.put(id, dataLinksTypesAndTitles);
-        }
+        this.data.put(id, metric.getData());
       }
     }
     for (Category category :
diff --git a/website/web/WEB-INF/graph.jsp b/website/web/WEB-INF/graph.jsp
index 8d5c5db..1299b6a 100644
--- a/website/web/WEB-INF/graph.jsp
+++ b/website/web/WEB-INF/graph.jsp
@@ -156,7 +156,7 @@
 <h4>Underlying data</h4>
 <ul>
 <c:forEach var="row" items="${data}">
-<li><a href="${row[0]}">${row[1]}</a></li>
+<li><a href="stats.html#${row}"><code>stats/${row}.csv</code></a></li>
 </c:forEach>
 </ul>
 </c:if>
diff --git a/website/web/WEB-INF/link.jsp b/website/web/WEB-INF/link.jsp
index dcead41..c017c03 100644
--- a/website/web/WEB-INF/link.jsp
+++ b/website/web/WEB-INF/link.jsp
@@ -42,7 +42,7 @@
               <h4>Underlying data</h4>
               <ul>
               <c:forEach var="row" items="${data}">
-              <li><a href="${row[0]}">${row[1]}</a></li>
+              <li><a href="stats.html#${row}"><code>stats/${row}.csv</code></a></li>
               </c:forEach>
               </ul>
               </c:if>
diff --git a/website/web/WEB-INF/stats.jsp b/website/web/WEB-INF/stats.jsp
index 2690e89..8ab2a00 100644
--- a/website/web/WEB-INF/stats.jsp
+++ b/website/web/WEB-INF/stats.jsp
@@ -19,6 +19,7 @@
     </div>
 
 <div class="container">
+<a name="servers" id="anchor-servers"></a>
 <h2>Number of relays and bridges</h2>
 
 <p>The following data file contains the number of running <a
@@ -85,6 +86,7 @@ only, this column contains the empty string.</li>
 </div>
 
 <div class="container">
+<a name="bandwidth" id="anchor-bandwidth"></a>
 <h2>Bandwidth provided and consumed by relays</h2>
 
 <p>The following data file contains statistics on <a
@@ -140,6 +142,7 @@ relays when serving directory data.</li>
 </div>
 
 <div class="container">
+<a name="advbwdist" id="anchor-advbwdist"></a>
 <h2>Advertised bandwidth distribution and n-th fastest relays</h2>
 
 <p>The following data file contains statistics on the distribution of <a
@@ -178,6 +181,7 @@ relays.</li>
 </div>
 
 <div class="container">
+<a name="clients" id="anchor-clients"></a>
 <h2>Estimated number of clients in the Tor network</h2>
 
 <p>The following data file contains estimates on the number of <a
@@ -242,6 +246,7 @@ should be handled with more care.</li>
 </div>
 
 <div class="container">
+<a name="userstats-combined" id="anchor-userstats-combined"></a>
 <h2>Estimated number of clients by country and transport</h2>
 
 <p>The following data file contains additional statistics on the number of <a
@@ -306,6 +311,7 @@ there are users by either of the two numbers.</li>
 </div>
 
 <div class="container">
+<a name="torperf" id="anchor-torperf"></a>
 <h2>Performance of downloading static files over Tor</h2>
 
 <p>The following data file contains aggregate statistics on performance when
@@ -356,6 +362,7 @@ over Tor.</li>
 </div>
 
 <div class="container">
+<a name="connbidirect2" id="anchor-connbidirect2"></a>
 <h2>Fraction of connections used uni-/bidirectionally</h2>
 
 <p>The following data file contains statistics on the fraction of direct
@@ -398,6 +405,7 @@ fractions for the three directions "read", "write", and "both" sum up to exactly
 </div>
 
 <div class="container">
+<a name="hidserv" id="anchor-hidserv"></a>
 <h2>Hidden-service statistics</h2>
 
 <p>The following data file contains <a
@@ -442,6 +450,7 @@ fraction.</li>
 </div>
 
 <div class="container">
+<a name="disagreement" id="anchor-disagreement"></a>
 <h2>Disagreement among the directory authorities (deprecated)</h2>
 
 <div class="bs-callout bs-callout-warning">
diff --git a/website/web/WEB-INF/table.jsp b/website/web/WEB-INF/table.jsp
index b6fd541..bcc9c4d 100644
--- a/website/web/WEB-INF/table.jsp
+++ b/website/web/WEB-INF/table.jsp
@@ -72,7 +72,7 @@
 <h4>Underlying data</h4>
 <ul>
 <c:forEach var="row" items="${data}">
-<li><a href="${row[0]}">${row[1]}</a></li>
+<li><a href="stats.html#${row}"><code>stats/${row}.csv</code></a></li>
 </c:forEach>
 </ul>
 </c:if>





More information about the tor-commits mailing list