Sha256: a8da7c00b7ce9746c61a83f9c54c4f74ba06d1f61d29f22be3ec189aad2e526d
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
def puts! a, b='' puts "+++ +++ #{b}" puts a.inspect end namespace :office do desc 'scheduled email actions, rolling perform' task schs: :environment do while true do Sch.active.where({ :perform_at.lte => Time.now }).each do |sch| sch.update_attributes({ state: Sch::STATE_INACTIVE }) # send now ctx = Ctx.new({ email_template_id: sch.act.tmpl.id, lead_id: sch.lead.id, send_at: Time.now, subject: sch.act.tmpl.subject, from_email: sch.act.tmpl.from_email, scheduled_email_action_id: sch.act.id, }) ctx.save! # schedule next actions & update the action sch.act.ties.each do |tie| next_act = tie.next_email_action next_at = eval(tie.next_at_exe) next_sch = Sch.find_or_initialize_by({ lead_id: sch.lead_id, email_action_id: next_act.id, }) next_sch.perform_at = next_at next_sch.state = Sch::STATE_ACTIVE next_sch.save! end print '+' end # sleep 1.minute sleep 10.seconds print '.' end end desc "send emails" task email_worker: :environment do while true do ctxs = ::Ish::EmailContext.scheduled.notsent ctxs.map do |ctx| IshManager::OfficeMailer.send_context_email( ctx[:id].to_s ).deliver_later print '^' end sleep 60 # seconds print '.' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ish_manager-0.1.8.403 | lib/tasks/office_tasks.rake |
ish_manager-0.1.8.402 | lib/tasks/office_tasks.rake |