# HG changeset patch # User Chris Cannam # Date 1351171182 -3600 # Node ID 9b4919de5317fe5bc488eb5f118ae97511f2ac10 # Parent 56a38a9f62040e113c4c9192ce4374de3947222e Print out the results diff -r 56a38a9f6204 -r 9b4919de5317 extra/soundsoftware/get-apache-log-stats.rb --- a/extra/soundsoftware/get-apache-log-stats.rb Thu Oct 25 14:08:58 2012 +0100 +++ b/extra/soundsoftware/get-apache-log-stats.rb Thu Oct 25 14:19:42 2012 +0100 @@ -1,6 +1,6 @@ -# Read an Apache log file from the SoundSoftware site and produce some -# per-project stats. +# Read an Apache log file in SoundSoftware site format from stdin and +# produce some per-project stats. # # Invoke with e.g. # @@ -55,6 +55,12 @@ end end +def print_stats(h) + h.keys.sort { |a,b| h[b] <=> h[a] }.each do |p| + print h[p], " ", @projects[p].name, "\n" + end +end + STDIN.each do |line| record = parser.parse(line) @@ -131,7 +137,6 @@ next end - project = project.split("?")[0] hits[project] += 1 end @@ -146,11 +151,20 @@ pulls[project] -= 1 end -print clones, "\n" -print pulls, "\n" -print pushes, "\n" -print zips, "\n" -print hits, "\n" +print "\nMercurial clones:\n" +print_stats clones + +print "\nMercurial pulls (excluding clones):\n" +print_stats pulls + +print "\nMercurial pushes:\n" +print_stats pushes + +print "\nMercurial archive (zip file) downloads:\n" +print_stats zips + +print "\nProject page hits:\n" +print_stats hits print parseable, " parseable\n" print unparseable, " unparseable\n"