Skip to content

Commit 9d78cba

Browse files
committed
Add the first job; helps if you call super
1 parent 08afbfd commit 9d78cba

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

app/jobs/application_job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class ApplicationJob < ActiveJob::Base
77

88
def initialize
99
@job_id = SecureRandom.uuid
10+
super
1011
end
1112

1213
def logger

app/jobs/auto_close_complaints_job.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ class AutoCloseComplaintsJob < ApplicationJob
44
def perform(*_args)
55
complaints = Complaint.where(status: 'reviewed')
66
.where(Arel.sql('status_updated_at <= ?', 14.days.ago))
7-
complaints.each do |complaint|
7+
statuses = complaints.map do |complaint|
88
complaint.update_status 'closed'
99
end
10+
successful = statuses.map { |x| x && 1 || 0 }.sum
11+
logger.info "Found #{complaints.size} inactive complaints, successfully closed #{successful} of them."
1012
end
1113
end

0 commit comments

Comments
 (0)