Module: PricingPlans::PlanOwner::ClassMethods
- Defined in:
- lib/pricing_plans/plan_owner.rb
Instance Method Summary collapse
-
#in_grace_period ⇒ Object
Plan owners with limits in grace period (exceeded but not yet blocked).
-
#needing_attention ⇒ Object
Alias for with_exceeded_limits - plan owners that need attention (either exceeded or blocked on any limit).
-
#with_blocked_limits ⇒ Object
Plan owners with any limit that is blocked (blocked_at is set).
-
#with_exceeded_limits ⇒ Object
Plan owners with any limit that has been exceeded (exceeded_at is set) Includes both those in grace period and those that are blocked.
-
#within_all_limits ⇒ Object
Plan owners with no exceeded limits (complement of with_exceeded_limits).
Instance Method Details
#in_grace_period ⇒ Object
Plan owners with limits in grace period (exceeded but not yet blocked)
129 130 131 132 133 134 |
# File 'lib/pricing_plans/plan_owner.rb', line 129 def in_grace_period joins_enforcement_states .where.not(pricing_plans_enforcement_states: { exceeded_at: nil }) .where(pricing_plans_enforcement_states: { blocked_at: nil }) .distinct end |
#needing_attention ⇒ Object
Alias for with_exceeded_limits - plan owners that need attention (either exceeded or blocked on any limit)
145 146 147 |
# File 'lib/pricing_plans/plan_owner.rb', line 145 def needing_attention with_exceeded_limits end |
#with_blocked_limits ⇒ Object
Plan owners with any limit that is blocked (blocked_at is set)
124 125 126 |
# File 'lib/pricing_plans/plan_owner.rb', line 124 def with_blocked_limits joins_enforcement_states.where.not(pricing_plans_enforcement_states: { blocked_at: nil }).distinct end |
#with_exceeded_limits ⇒ Object
Plan owners with any limit that has been exceeded (exceeded_at is set) Includes both those in grace period and those that are blocked.
119 120 121 |
# File 'lib/pricing_plans/plan_owner.rb', line 119 def with_exceeded_limits joins_enforcement_states.where.not(pricing_plans_enforcement_states: { exceeded_at: nil }).distinct end |
#within_all_limits ⇒ Object
Plan owners with no exceeded limits (complement of with_exceeded_limits). Uses LEFT OUTER JOIN for better performance than subquery on large tables.
138 139 140 141 |
# File 'lib/pricing_plans/plan_owner.rb', line 138 def within_all_limits left_outer_joins_exceeded_enforcement_states .where(pricing_plans_enforcement_states: { id: nil }) end |