Revision 984:8b6acaabe2da extra/soundsoftware

View differences:

extra/soundsoftware/get-apache-log-stats.rb
41 41
def is_public_project?(project)
42 42
  if !project
43 43
    false
44
  elsif project =~ /^\d+$/
45
    # ignore numerical project ids, they are only used when editing projects
46
    false
44 47
  elsif @projects.key?(project)
45 48
    @projects[project].is_public? 
46 49
  else
......
57 60

  
58 61
def print_stats(h)
59 62
  h.keys.sort { |a,b| h[b] <=> h[a] }.each do |p|
60
    print h[p], " ", @projects[p].name, "\n"
63
    if h[p] > 0
64
      print h[p], " ", @projects[p].name, " [", p, "]\n"
65
    end
61 66
  end
62 67
end
63 68

  
......
67 72

  
68 73
  # most annoyingly, the parser can't handle the comma-separated list
69 74
  # in X-Forwarded-For where it has more than one element. If it has
70
  # failed, remove any IP addresses with trailing commas and try again
75
  # failed, remove any IP addresses or the word "unknown" with
76
  # trailing commas and try again
71 77
  if not record
72
    filtered = line.gsub(/([0-9]+\.){3}[0-9]+,\s*/, "")
78
    filtered = line.gsub(/(unknown|([0-9]+\.){3}[0-9]+),\s*/, "")
73 79
    record = parser.parse(filtered)
74 80
  end
75 81

  
......
151 157
  pulls[project] -= 1
152 158
end
153 159

  
160
print parseable, " parseable\n"
161
print unparseable, " unparseable\n"
162

  
163

  
154 164
print "\nMercurial clones:\n"
155 165
print_stats clones
156 166

  
......
163 173
print "\nMercurial archive (zip file) downloads:\n"
164 174
print_stats zips
165 175

  
166
print "\nProject page hits:\n"
176
print "\nProject page hits (excluding crawlers):\n"
167 177
print_stats hits
168 178

  
169
print parseable, " parseable\n"
170
print unparseable, " unparseable\n"
171 179

  

Also available in: Unified diff