Sha256: ca3b9b4f303ce8842538e0b036ebd804ddc859817b9c13a577b817f2e8f5b4e4

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

# == Schema Information
#
# Table name: counter_changes
#
#  id               :integer          not null, primary key
#  counter_value_id :integer          indexed
#  amount           :integer
#  processed_at     :datetime         indexed
#  created_at       :datetime         not null
#  updated_at       :datetime         not null
#
class Counter::Change < ApplicationRecord
  def self.table_name_prefix
    "counter_"
  end

  belongs_to :counter, class_name: "Counter::Value"
  validates_numericality_of :amount

  scope :pending, -> { where(reconciled_at: nil) }
  scope :reconciled, -> { where.not(reconciled_at: nil) }
  scope :purgable, -> { reconciled.where(processed_at: 7.days.ago..) }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
counterwise-0.1.1 app/models/counter/change.rb
counterwise-0.1.0 app/models/counter/change.rb