Sha256: dc6467b3b9a306099968bd64b18a12175d0732becc88ef0d9e97aae507506bdd

Contents?: true

Size: 1.54 KB

Versions: 55

Compression:

Stored size: 1.54 KB

Contents

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.send_and_roll

        print '+'
      end

      # sleep 1.minute
      sleep 10.seconds
      print '.'
    end
  end

  desc 'office actions exe, rolling perform'
  task oacts: :environment do
    while true do

      ## send and roll
      Office::Action.active.where({ :perform_at.lte => Time.now }).each do |oact|

        oact.update({
          perform_at: nil,
          # state: OAct::STATE_INACTIVE, ## @TODO: remove, they remain active but non-perform.
        })
        eval( oact.action_exe )
        oact.ties.each do |tie|
          next_oact            = tie.next_office_action
          next_oact.perform_at = eval(tie.next_at_exe)
          next_oact.state      = OAct::STATE_ACTIVE
          next_oact.save!
        end

        print '+'
      end

      duration = Rails.env.production? ? 360 : 15 # 6 minutes or 15 seconds
      sleep duration
      print '.'
    end
  end

  ## 2023-04-02 _vp_ Continue.
  desc "send emails"
  task ctxs: :environment do
    while true do

      ctxs = ::Ish::EmailContext.scheduled.notsent
      ctxs.map do |ctx|
        out = IshManager::OfficeMailer.send_context_email( ctx[:id].to_s )
        Rails.env.production? ? out.deliver_later : out.deliver_now
        print '^'
      end

      duration = Rails.env.production? ? 120 : 15 # 2 minutes or 15 seconds
      sleep duration
      print '.'
    end
  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
ish_manager-0.1.8.468 lib/tasks/office_tasks.rake
ish_manager-0.1.8.467 lib/tasks/office_tasks.rake
ish_manager-0.1.8.466 lib/tasks/office_tasks.rake
ish_manager-0.1.8.465 lib/tasks/office_tasks.rake
ish_manager-0.1.8.464 lib/tasks/office_tasks.rake
ish_manager-0.1.8.463 lib/tasks/office_tasks.rake
ish_manager-0.1.8.462 lib/tasks/office_tasks.rake
ish_manager-0.1.8.461 lib/tasks/office_tasks.rake
ish_manager-0.1.8.460 lib/tasks/office_tasks.rake
ish_manager-0.1.8.459 lib/tasks/office_tasks.rake
ish_manager-0.1.8.458 lib/tasks/office_tasks.rake
ish_manager-0.1.8.457 lib/tasks/office_tasks.rake
ish_manager-0.1.8.456 lib/tasks/office_tasks.rake
ish_manager-0.1.8.455 lib/tasks/office_tasks.rake
ish_manager-0.1.8.454 lib/tasks/office_tasks.rake
ish_manager-0.1.8.453 lib/tasks/office_tasks.rake
ish_manager-0.1.8.452 lib/tasks/office_tasks.rake
ish_manager-0.1.8.451 lib/tasks/office_tasks.rake
ish_manager-0.1.8.450 lib/tasks/office_tasks.rake
ish_manager-0.1.8.449 lib/tasks/office_tasks.rake