Skip to content

Commit

Permalink
fix alphabetical ordering of a few fields and alphabetize the order o…
Browse files Browse the repository at this point in the history
…f the relations and inside enumerables as well
  • Loading branch information
danarnold committed Jul 5, 2023
1 parent ca4f39f commit 98d5895
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/fabric/app/models/fabric/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class Subscription

belongs_to :customer, class_name: 'Fabric::Customer', touch: true,
primary_key: :stripe_id
has_many :subscription_items, class_name: 'Fabric::SubscriptionItem',
primary_key: :stripe_id, dependent: :destroy
belongs_to :default_payment_method, class_name: 'Fabric::PaymentMethod',
primary_key: :stripe_id
belongs_to :latest_invoice, class_name: 'Fabric::Invoice',
primary_key: :stripe_id, foreign_key: :latest_invoice_id, inverse_of: nil
belongs_to :pending_setup_intent, class_name: 'Fabric::SetupIntent',
primary_key: :stripe_id, foreign_key: :pending_setup_intent_id,
inverse_of: nil
has_many :subscription_items, class_name: 'Fabric::SubscriptionItem',
primary_key: :stripe_id, dependent: :destroy

alias_method :items, :subscription_items

Expand All @@ -34,22 +34,22 @@ class Subscription
field :current_period_end, type: Time
field :current_period_start, type: Time
field :days_until_due, type: Integer
field :description, type: String
field :default_tax_rates, type: Array
field :description, type: String
field :discount, type: Hash
field :ended_at, type: Time
field :livemode, type: Boolean
field :next_pending_invoice_item_invoice, type: Time
field :metadata, type: Hash
field :next_pending_invoice_item_invoice, type: Time
field :pause_collection, type: Hash
field :payment_settings, type: Hash
field :pending_invoice_item_interval, type: Hash
field :pending_update, type: Hash
field :start_date, type: Time
field :status, type: String
enumerize :status, in: %w[
trialing active past_due canceled unpaid incomplete incomplete_expired
paused
active canceled incomplete incomplete_expired past_due paused trialing
unpaid
]
field :tax_percent, type: Float
field :trial_end, type: Time
Expand All @@ -60,11 +60,11 @@ class Subscription
validates_presence_of :stripe_id, :customer_id, :status

scope :active, -> { where(status: 'active') }
scope :billing, -> { where(:status.in => %w[trialing active past_due]) }
scope :billing, -> { where(:status.in => %w[active past_due trialing]) }
scope :non_canceled, lambda {
where(:status.in => %w[trialing active past_due unpaid paused])
where(:status.in => %w[active past_due paused trialing unpaid])
}
scope :unpaid, -> { where(:status.in => %w[unpaid past_due]) }
scope :unpaid, -> { where(:status.in => %w[past_due unpaid]) }

index({ stripe_id: 1 }, { background: true, unique: true })
index({ status: 1 }, background: true)
Expand Down

0 comments on commit 98d5895

Please sign in to comment.