Created
April 3, 2017 04:51
-
-
Save kklimuk/ab3cf0ac9539697b6e7c022726f7f8b7 to your computer and use it in GitHub Desktop.
This file contains 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| | |
users.payment_plan.discounts.any? && !users.payment_plan.delayed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment