Class: AutoCloseComplaintsJob

Inherits:
ApplicationJob show all
Defined in:
/var/apps/qpixel/app/jobs/auto_close_complaints_job.rb

Instance Method Summary collapse

Methods inherited from ApplicationJob

#exec, #initialize, #logger

Constructor Details

This class inherits a constructor from ApplicationJob

Instance Method Details

#perform(*_args) ⇒ Object



4
5
6
7
8
9
10
11
12
# File '/var/apps/qpixel/app/jobs/auto_close_complaints_job.rb', line 4

def perform(*_args)
  complaints = Complaint.where(status: 'reviewed')
                        .where(Arel.sql('status_updated_at <= ?', 14.days.ago))
  statuses = complaints.map do |complaint|
    complaint.update_status 'closed'
  end
  successful = statuses.compact_blank.size
  logger.info "Found #{complaints.size} inactive complaints, successfully closed #{successful} of them."
end