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

[tor-commits] [onionoo/release] Log less frequently requested parameter combinations.



commit 8ea8ab0fa06c566c66811a9970f5633cfd90d186
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Sun Jul 29 21:42:57 2018 +0200

    Log less frequently requested parameter combinations.
    
    Implements the first part of #26919, which is to find out whether the
    "fingerprint" parameter is used at all.
---
 CHANGELOG.md                                                     | 4 ++++
 .../java/org/torproject/onionoo/server/MostFrequentString.java   | 9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d024d83..f3428c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,10 @@
    - Support a comma-separated list of AS numbers in the "as"
      parameter.
 
+ * Minor changes
+   - Extend internal statistics to log less frequently requested
+     resources and parameter combinations without counts.
+
 
 # Changes in version 6.1-1.15.0 - 2018-07-16
 
diff --git a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
index 9fa51c7..c677bb5 100644
--- a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
+++ b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java
@@ -43,17 +43,20 @@ class MostFrequentString {
     StringBuilder sb = new StringBuilder();
     int stringsToAdd = 3;
     int written = 0;
+    SortedSet<String> remainingStrings = new TreeSet<>();
     for (Map.Entry<Integer, SortedSet<String>> e :
         sortedFrequencies.entrySet()) {
       for (String string : e.getValue()) {
         if (stringsToAdd-- > 0) {
           sb.append((written++ > 0 ? ", " : "") + string + " ("
               + e.getKey() + ")");
+        } else {
+          remainingStrings.add(string);
         }
       }
-      if (stringsToAdd == 0) {
-        break;
-      }
+    }
+    for (String string : remainingStrings) {
+      sb.append(", ").append(string);
     }
     return sb.toString();
   }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits