Sha256: c4d7ca82a1b07fe8baa4aaf42dfff83d3a907c1e4d484fac720b051a1cd1f094

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

module ErpTechSvcs
  module Sessions
    # Delayed Job to Reset Daily Assignments to Forecast
    class DeleteExpiredSessionsJob  

      def initialize
        @priority = 1
      end
  
      def perform
        begin
          process_job
        rescue => exception
          ErpTechSvcs::Util::CompassLogger.delete_expired_sessions_job.error("An unrecoverable error has occured, the job will be rescheduled: #{exception.message} : #{exception.backtrace}")
        end
    
        # Run once per day
        date = Date.tomorrow
        start_time = DateTime.civil(date.year, date.month, date.day, 2, 0, 1, -(5.0/24.0))
    
        Delayed::Job.enqueue(DeleteExpiredSessionsJob.new(), @priority, start_time)
      end

      def self.schedule_job(schedule_dt)
        Delayed::Job.enqueue(DeleteExpiredSessionsJob.new(), @priority, schedule_dt)
      end

      def process_job
        start_time = Time.now
    
        ErpTechSvcs::Sessions::DeleteExpiredSessionsService.new.execute
    
        end_time = Time.now
    
        return end_time - start_time
      end
  
    end #Close DeleteExpiredSessionsJob
  end #Close Sessions
end #Close ErpTechSvcs

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
erp_tech_svcs-3.1.2 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.1.1 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.12 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.1.0 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.11 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.10 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.9 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.8 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.7 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.6 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.5 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.4 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.3 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.2 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.1 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb
erp_tech_svcs-3.0.0 lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb