tracks/lib/staleness.rb

17 lines
436 B
Ruby
Raw Normal View History

require 'active_support/all'
class Staleness
SECONDS_PER_DAY = 86400
def self.days_stale(item, current_user)
return 0 if cannot_be_stale(item, current_user)
2013-07-30 16:18:06 -05:00
(UserTime.new(current_user).time - item.created_at).to_i / SECONDS_PER_DAY
end
def self.cannot_be_stale(item, current_user)
return true if item.due || item.completed?
2013-07-30 16:18:06 -05:00
return true if item.created_at > UserTime.new(current_user).time
false
end
end