lib/solidus_subscriptions/processor.rb
def batched_users_to_be_processed
        subscriptions = SolidusSubscriptions::Subscription.arel_table
        installments = SolidusSubscriptions::Installment.arel_table

        Spree::User.
          joins(:subscriptions).
          joins(
            subscriptions.
              join(installments, Arel::Nodes::OuterJoin).
              on(subscriptions[:id].eq(installments[:subscription_id])).
              join_sources
          ).
          where(
            SolidusSubscriptions::Subscription.actionable.arel.constraints.reduce(:and).
              or(SolidusSubscriptions::Installment.actionable.arel.constraints.reduce(:and))
          ).
          distinct.
          find_in_batches
      end
# Find all actionable subscriptions and intallments, group them together
# by user, and schedule a processing job for the group as a batch
Find all actionable subscriptions and intallments, group them together
by user, and schedule a processing job for the group as a batch
Find all actionable subscriptions and intallments group them together by user and schedule a processing job for the group as a batch
def batched_users_to_be_processed
        subscriptions = SolidusSubscriptions::Subscription.arel_table
        installments = SolidusSubscriptions::Installment.arel_table
        Spree::User.
          joins(:subscriptions).
          joins(
            subscriptions.
              join(installments, Arel::Nodes::OuterJoin).
              on(subscriptions[:id].eq(installments[:subscription_id])).
              join_sources
          ).
          where(
            SolidusSubscriptions::Subscription.actionable.arel.constraints.reduce(:and).
              or(SolidusSubscriptions::Installment.actionable.arel.constraints.reduce(:and))
          ).
          distinct.
          find_in_batches
      end
def batched_users_to_be_processed subscriptions = SolidusSubscriptions :: Subscription . arel_table installments = SolidusSubscriptions :: Installment . arel_table Spree :: User . joins ( :subscriptions ) . joins ( subscriptions . join ( installments , Arel :: Nodes :: OuterJoin ) . on ( subscriptions [ :id ] . eq ( installments [ :subscription_id ] ) ) . join_sources ) . where ( SolidusSubscriptions :: Subscription . actionable . arel . constraints . reduce ( :and ) . or ( SolidusSubscriptions :: Installment . actionable . arel . constraints . reduce ( :and ) ) ) . distinct . find_in_batches end
Find all actionable subscriptions and intallments, group them together
by user, and schedule a processing job for the group as a batch
Find all actionable subscriptions and intallments group them together by user and schedule a processing job for the group as a batch