Improved background job.
This commit is contained in:
parent
f2d1882238
commit
e38ca9c2b8
2 changed files with 15 additions and 9 deletions
|
@ -19,7 +19,12 @@ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
|
||||||
return if !record.customer_id
|
return if !record.customer_id
|
||||||
|
|
||||||
# send background job
|
# send background job
|
||||||
Delayed::Job.enqueue( Observer::Ticket::UserTicketCounter::BackgroundJob.new( record.customer_id ) )
|
Delayed::Job.enqueue(
|
||||||
|
Observer::Ticket::UserTicketCounter::BackgroundJob.new(
|
||||||
|
record.customer_id,
|
||||||
|
UserInfo.current_user_id || record.updated_by_id,
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Observer::Ticket::UserTicketCounter::BackgroundJob
|
class Observer::Ticket::UserTicketCounter::BackgroundJob
|
||||||
def initialize(id)
|
def initialize(customer_id, updated_by_id)
|
||||||
@customer_id = id
|
@customer_id = customer_id
|
||||||
|
@updated_by_id = updated_by_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
@ -32,7 +33,7 @@ class Observer::Ticket::UserTicketCounter::BackgroundJob
|
||||||
end
|
end
|
||||||
|
|
||||||
return if !need_update
|
return if !need_update
|
||||||
|
customer.updated_by_id = @updated_by_id
|
||||||
customer.save
|
customer.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue