This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
memoized | |
def users_with_discounts(scoped_to={}) | |
users = User.includes(payment_plan: :discounts).where(paying: true, **scoped_to).to_a | |
users.select do |users| | |
users.payment_plan.discounts.any? && !users.payment_plan.delayed? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts | |
return @users_with_discounts unless @users_with_discounts.nil? | |
@users_with_discounts = computation_that_returns_nil || false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts | |
@users_with_discounts ||= computation_that_returns_nil | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts(scoped_to={}) | |
@users_with_discounts ||= {} | |
return @users_with_discounts[scoped_to] if @users_with_discounts.has_key?(scoped_to) | |
users = User.includes(payment_plan: :discounts).where( | |
paying: true, | |
**scoped_to | |
).to_a | |
@users_with_discounts[scoped_to] = users.select do |users| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts | |
return @users_with_discounts unless @users_with_discounts.nil? | |
users = User.includes(payment_plan: :discounts).where(paying: true).to_a | |
@users_with_discounts = users.select do |users| | |
users.payment_plan.discounts.any? && !users.payment_plan.delayed? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts | |
@users_with_discounts ||= User.includes(payment_plan: :discounts).where(paying: true).to_a | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def users_with_discounts | |
User.includes(payment_plan: :discounts).where(paying: true).to_a | |
end |
NewerOlder