Skip to content

Instantly share code, notes, and snippets.

@samanthamjohn
Created January 8, 2015 21:04
Show Gist options
  • Save samanthamjohn/20250ce8a12ba4e5d661 to your computer and use it in GitHub Desktop.
Save samanthamjohn/20250ce8a12ba4e5d661 to your computer and use it in GitHub Desktop.
A script for finding what percentage of projects are liked/starred/etc
categories = Category.all
categories.each do |c|
has_been_played = c.projects.where("has_been_removed IS NOT TRUE AND play_count > 0").count
all_projects = c.projects.where("has_been_removed IS NOT TRUE").count
ratio = has_been_played.to_f/all_projects.to_f
puts "#{c.label} has #{ratio*100} percent played"
has_been_starred = c.projects.where("has_been_removed IS NOT TRUE AND stars_count > 0").count
ratio = has_been_played.to_f/all_projects.to_f
puts "#{c.label} has #{ratio*100} percent played"
puts "#{c.label} has #{ratio*100} percent played"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment