Skip to content

Instantly share code, notes, and snippets.

@rumblex
Created October 21, 2008 01:55
Show Gist options
  • Select an option

  • Save rumblex/18231 to your computer and use it in GitHub Desktop.

Select an option

Save rumblex/18231 to your computer and use it in GitHub Desktop.
Settings.voting_begin = Time.now.to_s
Competition.setup!
def doit(iterations = 10)
total_time = 0.0
count = 0
iterations.times do
entry = Entry.find(:first, :order => 'RAND()')
user = User.find(:first, :order => 'RAND()')
user.can_rate(entry)
ratings = {
'appearance' => rand(5) + 1,
'completeness' => rand(5) + 1,
'innovation' => rand(5) + 1,
'usefulness' => rand(5) + 1,
}
ts = Time.new
ratings.each do |cat, value|
entry.rate(value.to_i, :category => cat, :user => user)
count += 1
end
tf = Time.new
total_time += tf.to_f - ts.to_f
end
puts "#{count} Ratings added in #{total_time.to_s}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment