[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #21587 [Metrics/Metrics website]: Improve running bridges statistic by skipping statuses without any running bridges



#21587: Improve running bridges statistic by skipping statuses without any running
bridges
-------------------------------------+------------------------------
 Reporter:  karsten                  |          Owner:  metrics-team
     Type:  defect                   |         Status:  needs_review
 Priority:  Medium                   |      Milestone:
Component:  Metrics/Metrics website  |        Version:
 Severity:  Normal                   |     Resolution:
 Keywords:                           |  Actual Points:
Parent ID:                           |         Points:
 Reviewer:                           |        Sponsor:
-------------------------------------+------------------------------
Changes (by karsten):

 * status:  new => needs_review


Comment:

 Here's a possible fix:

 {{{
 diff --git
 a/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
 b/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
 index 9aef3e4..801794f 100644
 ---
 a/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
 +++
 b/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
 @@ -257,17 +257,23 @@ public class ConsensusStatsFileHandler {
       * and bridge authority. */
      Map<String, Map<String, int[]>> bridgesPerDayAndAuthority = new
 HashMap<>();
      for (String bridgesRawLine : this.bridgesRaw.values()) {
 +      String[] parts = bridgesRawLine.split(",");
 +      int brunning = Integer.parseInt(parts[2]);
 +      if (brunning <= 0) {
 +        /* Skip this status which contains zero bridges with the Running
 +         * flag. */
 +        continue;
 +      }
        String date = bridgesRawLine.substring(0, 10);
        if (!bridgesPerDayAndAuthority.containsKey(date)) {
          bridgesPerDayAndAuthority.put(date, new TreeMap<String,
 int[]>());
        }
 -      String[] parts = bridgesRawLine.split(",");
        String authority = parts[1];
        if (!bridgesPerDayAndAuthority.get(date).containsKey(authority)) {
          bridgesPerDayAndAuthority.get(date).put(authority, new int[3]);
        }
        int[] bridges = bridgesPerDayAndAuthority.get(date).get(authority);
 -      bridges[0] += Integer.parseInt(parts[2]);
 +      bridges[0] += brunning;
        bridges[1] += Integer.parseInt(parts[3]);
        bridges[2]++;
      }
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/21587#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs