Skip to content

Instantly share code, notes, and snippets.

@tsnow
Created April 15, 2010 18:25
Show Gist options
  • Save tsnow/367457 to your computer and use it in GitHub Desktop.
Save tsnow/367457 to your computer and use it in GitHub Desktop.
Delayed::Job.delete_all;
{
TradePlan => :work_listing_affinities,
SearchPlan => :work_listing_affinities}.each do |klass,method|
klass.all.each{|k| k.send_later(method)}
end
{ Address => [:cycle_location_and_geocode_and_save, 0, true],
SearchPlan => [:calc_important_affinities, 2, false]}.each do |klass,method_priority|
method = method_priority[0]
priority = method_priority[1]
later = method_priority[2]
count = 0
klass.all.each do |k|
count += 1
Delayed::Job.enqueue Delayed::PerformableMethod.new(k,:send,[method]), priority, ( later ? count.minutes.from_now : nil)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment