Browse Source

Merge remote-tracking branch 'origin/master'

develop v2.6.1
Arthur POULET 1 month ago
parent
commit
d4de167df2
Signed by: Sceptique GPG Key ID: C108A668349EE601
  1. 14
      src/models/user.rb
  2. 6
      src/views/layout.slim

14
src/models/user.rb

@ -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

6
src/views/layout.slim

@ -39,7 +39,11 @@ html lang="en"
li.nav-item
a.btn.btn-lg.btn-dark href="/yesterday" Yesterday
li.nav-item
a.btn.btn-lg.btn-dark href="/recap" Recap
a.btn.btn-lg.btn-dark.position-relative href="/recap"
| Recap
- if (recalls_count = current_user.recalls_not_validated.count) > 0
span.position-absolute.top-0.start-100.translate-middle.badge.rounded-pill.bg-danger
= recalls_count
li.nav-item
a.btn.btn-lg.btn-dark href="/achievements" Achievements
li.nav-item

Loading…
Cancel
Save