forked from sigmike/peer4commit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtip.rb
More file actions
28 lines (21 loc) · 783 Bytes
/
tip.rb
File metadata and controls
28 lines (21 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Tip < ActiveRecord::Base
belongs_to :user
belongs_to :sendmany
belongs_to :project
validates :amount, :numericality => { :greater_than => 0 }
scope :unpaid, -> { non_refunded.
where(sendmany_id: nil) }
scope :paid, -> { where('sendmany_id is not ?', nil) }
scope :refunded, -> { where('refunded_at is not ?', nil) }
scope :non_refunded, -> { where(refunded_at: nil) }
scope :unclaimed, -> { joins(:user).
unpaid.
where('users.bitcoin_address' => ['', nil]) }
def self.refund_unclaimed
unclaimed.non_refunded.
where('tips.created_at < ?', Time.now - 1.month).
find_each do |tip|
tip.touch :refunded_at
end
end
end