Skip to content

Commit ec8e5d3

Browse files
authored
Merge pull request #196 from shiftcommerce/performance/explicitly_required_fields_on_customer_account
2 parents b85451e + c9cf04a commit ec8e5d3

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

app/models/cart.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ def available_shipping_methods
128128
private
129129

130130
def stock_levels
131-
StockLevel.where(skus: line_items.map { |li| li.item.sku }.join(",")).all
131+
StockLevel.with_params(fields: {stock_levels: "stock_available"}).where(skus: line_items.map { |li| li.item.sku }.join(",")).all
132132
end
133-
134-
135133
end
136134
end

app/models/customer_account.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ def self.authenticate(attributes = {})
5454
nil
5555
end
5656

57-
def self.find_by_email(email)
58-
requestor.custom("email:#{URI.encode_www_form_component(email)}", {request_method: :get}, {}).first
57+
def self.find_by_email(email, options = {})
58+
requestor.custom("email:#{URI.encode_www_form_component(email)}", {request_method: :get}, options).first
5959
rescue ::FlexCommerceApi::Error::NotFound
6060
nil
6161
end
6262

63-
def self.find_by_reference(reference)
64-
requestor.custom("reference:#{reference}", {request_method: :get}, {}).first
63+
def self.find_by_reference(reference, options = {})
64+
requestor.custom("reference:#{reference}", {request_method: :get}, options).first
6565
rescue ::FlexCommerceApi::Error::NotFound
6666
nil
6767
end
6868

6969
# Find customer account by password reset token provided in email's link
7070
# Used in reset password scenario
71-
def self.find_by_token(token)
72-
requestor.custom("token:#{token}", {request_method: :get}, {}).first
71+
def self.find_by_token(token, options = {})
72+
requestor.custom("token:#{token}", {request_method: :get}, options).first
7373
rescue ::FlexCommerceApi::Error::NotFound
7474
nil
7575
end

0 commit comments

Comments
 (0)