changeset 983:a97e573d7f87 cannam

Minor fixes
author Chris Cannam
date Thu, 25 Oct 2012 14:54:46 +0100
parents 6edb748be064
children 8b6acaabe2da acaa61dde68b 5beffb0393f7
files extra/soundsoftware/get-apache-log-stats.rb
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/extra/soundsoftware/get-apache-log-stats.rb	Thu Oct 25 14:25:43 2012 +0100
+++ b/extra/soundsoftware/get-apache-log-stats.rb	Thu Oct 25 14:54:46 2012 +0100
@@ -41,6 +41,9 @@
 def is_public_project?(project)
   if !project
     false
+  elsif project =~ /^\d+$/
+    # ignore numerical project ids, they are only used when editing projects
+    false
   elsif @projects.key?(project)
     @projects[project].is_public? 
   else
@@ -58,7 +61,7 @@
 def print_stats(h)
   h.keys.sort { |a,b| h[b] <=> h[a] }.each do |p|
     if h[p] > 0
-      print h[p], " ", @projects[p].name, "\n"
+      print h[p], " ", @projects[p].name, " [", p, "]\n"
     end
   end
 end
@@ -69,9 +72,10 @@
 
   # most annoyingly, the parser can't handle the comma-separated list
   # in X-Forwarded-For where it has more than one element. If it has
-  # failed, remove any IP addresses with trailing commas and try again
+  # failed, remove any IP addresses or the word "unknown" with
+  # trailing commas and try again
   if not record
-    filtered = line.gsub(/([0-9]+\.){3}[0-9]+,\s*/, "")
+    filtered = line.gsub(/(unknown|([0-9]+\.){3}[0-9]+),\s*/, "")
     record = parser.parse(filtered)
   end