tracks/lib/staleness.rb

18 lines
465 B
Ruby
Raw Permalink Normal View History

require 'active_support/all'
require 'user_time'
class Staleness
2020-10-10 13:58:13 +03:00
SECONDS_PER_DAY = 86_400
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
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