Class: Staleness

Inherits:
Object
  • Object
show all
Defined in:
lib/staleness.rb

Constant Summary collapse

SECONDS_PER_DAY =
86400

Class Method Summary collapse

Class Method Details

.cannot_be_stale(item, current_user) ⇒ Object


11
12
13
14
15
# File 'lib/staleness.rb', line 11

def self.cannot_be_stale(item, current_user)
  return true if item.due || item.completed?
  return true if item.created_at > UserTime.new(current_user).time
  false
end

.days_stale(item, current_user) ⇒ Object


6
7
8
9
# File 'lib/staleness.rb', line 6

def self.days_stale(item, current_user)
  return 0 if cannot_be_stale(item, current_user)
  (UserTime.new(current_user).time.utc - item.created_at.utc).to_i / SECONDS_PER_DAY
end