Sha256: 95f58b2f80d3cf89c8d99c9ec134ad717cd2b1b3bc2031e124515c94021b0a2f

Contents?: true

Size: 798 Bytes

Versions: 45

Compression:

Stored size: 798 Bytes

Contents

require 'business_time'
require 'httparty'

namespace :office do

  desc 'run_office_actions'
  task run_office_actions: :environment do
    while true do

      OA  = Wco::OfficeAction
      OAT = Wco::OfficeActionTemplate

      OA.active.where( :perform_at.lte => Time.now ).each do |oa|
        puts "+++ +++ Office Action: #{oa}"

        oa.update({ status: INACTIVE })
        oa.tmpl.do_run
        oa.tmpl.ties.each do |tie|
          next_oa = OA.find_or_initialize_by({
            office_action_template_id: tie.next_oat.id,
          })
          next_oa.perform_at = eval( tie.next_at_exe )
          next_oa.status     = ACTIVE
          next_oa.save!
        end

        print '^'
      end

      print '.'
      sleep Rails.env.production? ? 60 : 5 # seconds
    end
  end

end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
wco_models-3.1.0.83 lib/tasks/office_tasks.rake
wco_models-3.1.0.82 lib/tasks/office_tasks.rake
wco_models-3.1.0.81 lib/tasks/office_tasks.rake
wco_models-3.1.0.80 lib/tasks/office_tasks.rake
wco_models-3.1.0.79 lib/tasks/office_tasks.rake
wco_models-3.1.0.78 lib/tasks/office_tasks.rake
wco_models-3.1.0.77 lib/tasks/office_tasks.rake
wco_models-3.1.0.76 lib/tasks/office_tasks.rake
wco_models-3.1.0.75 lib/tasks/office_tasks.rake
wco_models-3.1.0.74 lib/tasks/office_tasks.rake
wco_models-3.1.0.73 lib/tasks/office_tasks.rake
wco_models-3.1.0.72 lib/tasks/office_tasks.rake
wco_models-3.1.0.71 lib/tasks/office_tasks.rake
wco_models-3.1.0.70 lib/tasks/office_tasks.rake
wco_models-3.1.0.69 lib/tasks/office_tasks.rake
wco_models-3.1.0.67 lib/tasks/office_tasks.rake
wco_models-3.1.0.66 lib/tasks/office_tasks.rake
wco_models-3.1.0.65 lib/tasks/office_tasks.rake
wco_models-3.1.0.64 lib/tasks/office_tasks.rake
wco_models-3.1.0.63 lib/tasks/office_tasks.rake