Revision 980:9b4919de5317

View differences:

extra/soundsoftware/get-apache-log-stats.rb
1 1

  
2
# Read an Apache log file from the SoundSoftware site and produce some
3
# per-project stats.
2
# Read an Apache log file in SoundSoftware site format from stdin and
3
# produce some per-project stats.
4 4
#
5 5
# Invoke with e.g.
6 6
#
......
55 55
  end
56 56
end
57 57

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

  
58 64
STDIN.each do |line|
59 65

  
60 66
  record = parser.parse(line)
......
131 137
      next
132 138
    end
133 139

  
134
    project = project.split("?")[0]
135 140
    hits[project] += 1
136 141

  
137 142
  end
......
146 151
  pulls[project] -= 1
147 152
end
148 153

  
149
print clones, "\n"
150
print pulls, "\n"
151
print pushes, "\n"
152
print zips, "\n"
153
print hits, "\n"
154
print "\nMercurial clones:\n"
155
print_stats clones
156

  
157
print "\nMercurial pulls (excluding clones):\n"
158
print_stats pulls
159

  
160
print "\nMercurial pushes:\n"
161
print_stats pushes
162

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

  
166
print "\nProject page hits:\n"
167
print_stats hits
154 168

  
155 169
print parseable, " parseable\n"
156 170
print unparseable, " unparseable\n"

Also available in: Unified diff