|
|
|
@ -6,4 +6,18 @@ class LifePex::User < Sequel::Model(:users)
|
|
|
|
|
def password=(clear_password) |
|
|
|
|
self.hashed_password = BCrypt::Password.create(clear_password) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def recalls_not_validated(cached: true) |
|
|
|
|
@recalls_not_validated = nil if !cached |
|
|
|
|
|
|
|
|
|
pexs = LifePex::Pex.setup_user_pexs(user_id: id, user_pexs: user_pexs) |
|
|
|
|
|
|
|
|
|
@recalls_not_validated ||= recalls.filter do |recall| |
|
|
|
|
pex = pexs[recall[:pex_id]] |
|
|
|
|
validated = pex[:count_by_date].filter do |date, _| |
|
|
|
|
date >= Date.today - recall[:span_duration] |
|
|
|
|
end.values.sum |
|
|
|
|
validated < recall[:repeated] |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|