Replaced delayed_job with resque. See README_DEVEL
This commit is contained in:
parent
344abf5a26
commit
2c0fe08be6
18 changed files with 82 additions and 74 deletions
|
|
@ -170,7 +170,7 @@ class Order < ActiveRecord::Base
|
|||
ordergroups.each(&:update_stats!)
|
||||
|
||||
# Notifications
|
||||
UserNotifier.delay.finished_order(self.id)
|
||||
Resque.enqueue(UserNotifier, FoodsoftConfig.scope, 'finished_order', self.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Ordergroup < Group
|
|||
save!
|
||||
# Notify only when order group had a positive balance before the last transaction:
|
||||
if t.amount < 0 && self.account_balance < 0 && self.account_balance - t.amount >= 0
|
||||
UserNotifier.delay.negative_balance(self.id, t.id)
|
||||
Resque.enqueue(UserNotifier, FoodsoftConfig.scope, 'negative_balance', self.id, t.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
# This plain ruby class should handle all user notifications, called by various models
|
||||
class UserNotifier
|
||||
|
||||
def self.finished_order(order_id)
|
||||
Order.find(order_id).group_orders.each do |group_order|
|
||||
group_order.ordergroup.users.each do |user|
|
||||
begin
|
||||
Mailer.order_result(user, group_order).deliver if user.settings["notify.orderFinished"] == '1'
|
||||
rescue
|
||||
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# If this order group's account balance is made negative by the given/last transaction,
|
||||
# a message is sent to all users who have enabled notification.
|
||||
def self.negative_balance(ordergroup_id, transaction_id)
|
||||
transaction = FinancialTransaction.find transaction_id
|
||||
|
||||
Ordergroup.find(ordergroup_id).users.each do |user|
|
||||
begin
|
||||
Mailer.negative_balance(user, transaction).deliver if user.settings["notify.negativeBalance"] == '1'
|
||||
rescue
|
||||
Rails.logger.warn "Can't deliver mail to #{user.email}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue