Skip to content

Instantly share code, notes, and snippets.

@kevinjalbert
Created January 13, 2015 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinjalbert/842ba37b94bb84dd2ed9 to your computer and use it in GitHub Desktop.
Save kevinjalbert/842ba37b94bb84dd2ed9 to your computer and use it in GitHub Desktop.
unique_log_urls
require 'uri'
files = Dir[ARGV[0]]
post_urls = Hash.new(0)
get_urls = Hash.new(0)
@exclude_url_regexes = Regexp.union([
/^\/admin/,
/^\/oauth2callback/,
/^\/assets/
])
files.each do |file|
File.open(file).each_line do |line|
matches = line.match(/(POST|GET)+\s*"(.*)"/)
next unless matches
url = matches[2]
if !url.match(@exclude_url_regexes)
action = matches[1]
if action == 'POST'
post_urls[url] += 1
else
get_urls[url] += 1
end
end
end
end
puts 'GETs'
Hash[get_urls.sort_by { |k, v| v }.reverse].each_pair do |k, v|
p "GET #{k} - #{v}"
end
puts ''
puts 'POSTs'
Hash[post_urls.sort_by { |k, v| v }.reverse].each_pair do |k, v|
p "POST #{k} - #{v}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment