You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
400 B
17 lines
400 B
6 years ago
|
class Attendance < ApplicationRecord
|
||
|
belongs_to :user
|
||
|
|
||
|
default_scope { order(created_at: :desc) }
|
||
|
|
||
|
def next_gold
|
||
|
# 超过1天即没有连续的签到则又从10个金币开始累加
|
||
|
return 50 if Util.days_between(Time.zone.now, created_at) > 1
|
||
|
|
||
|
[[score.to_i, 50].max + 10, 100].min
|
||
|
end
|
||
|
|
||
|
def today?
|
||
|
Util.days_between(Time.current, created_at).zero?
|
||
|
end
|
||
|
end
|