Skip to content

Commit

Permalink
Merge pull request #1048 from CasperSleep/multi_promocode_perf_improv…
Browse files Browse the repository at this point in the history
…ement

Fix performance issue on coupon code application for large sets
  • Loading branch information
jhawthorn committed Apr 7, 2016
2 parents 1a200b3 + 4740dcf commit d92dc8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/promotion_codes/index.csv.ruby
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CSV.generate do |csv|
csv << ['Code']
@promotion.codes.order(:id).each do |code|
csv << [code.value]
@promotion.codes.order(:id).pluck(:value).each do |value|
csv << [value]
end
end
2 changes: 1 addition & 1 deletion core/app/models/spree/promotion_handler/coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def promotion_exists_on_order?(order, promotion)

def determine_promotion_application_result
detector = lambda { |p|
p.source.promotion.codes.any? { |code| code.value == order.coupon_code.downcase }
p.source.promotion.codes.where(value: order.coupon_code.downcase).any?
}

# Check for applied adjustments.
Expand Down

0 comments on commit d92dc8a

Please sign in to comment.