Skip to content

Instantly share code, notes, and snippets.

@jhass
Created September 29, 2012 18:56
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 jhass/3804895 to your computer and use it in GitHub Desktop.
Save jhass/3804895 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require './config/environment'
def path_length(post, length=0)
if post.is_a?(Reshare)
path_length(post.root, length+1)
else
length
end
end
sum = 0.0
count = 0.0
max = 0.0
Reshare.all.each do |post|
length = path_length(post)
sum += length
count += 1
max = length > max ? length : max
end
puts "path length for #{count} reshares: average: #{sum/count}, max: #{max}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment