Created
April 2, 2014 21:06
-
-
Save braidn/9943193 to your computer and use it in GitHub Desktop.
Eligable orders
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
module Quarterly | |
class ApplicableRecipientsForIssueQuery | |
def initialize(issue, relation=Spree::User) | |
@issue = issue | |
@relation = relation | |
end | |
def call | |
@relation | |
.joins(:subscriptions) | |
.merge(Subscription.active) | |
.where("quarterly_subscriptions.plan_id = ?", @issue.plan_id) | |
# .where("NOT EXISTS (SELECT so.id FROM spree_orders so | |
# JOIN spree_line_items sli ON so.id = sli.order_id | |
# WHERE sli.variant_id = ? AND so.user_id = spree_users.id)", | |
# @issue.product_variant.id) | |
end | |
def find_each(&block) | |
call.find_each(&block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment