Class: RequestCleanupJob
- Inherits:
 - 
      ApplicationJob
      
        
- Object
 - ActiveJob::Base
 - ApplicationJob
 - RequestCleanupJob
 
 
- Defined in:
 - app/jobs/request_cleanup_job.rb
 
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
      5 6 7 8 9 10 11 12 13 14 15 16 17  | 
    
      # File 'app/jobs/request_cleanup_job.rb', line 5 def perform # Destroy every request in the database that is not valid to submit and has 6 or more errors Request.where.not(state: Request::SUBMITTED).each do |request| # check if the request has not been updated within 24 hours next unless request.updated_at < 24.hours.ago next if request.valid_title? request.valid_to_submit? # 6 errors is arbitrary, but it is the number of manditory fields (excluding pre-populated fields) in the request form if request.errors.count >= 6 request.destroy end end end  |