tracks/lib/staleness.rb
Matt Rogers ccf5323588 Encapsulate the concept of staleness into its own class
Extract it from a single helper method and wrap it in a method object.
This lets us add tests around it and then (later) split the domain
concerns from the view concerns.
2013-03-09 22:38:38 -06:00

18 lines
539 B
Ruby

require 'active_support/all'
class Staleness
def self.days_stale(item, current_user)
if item.due || item.completed?
return ""
elsif item.created_at < current_user.time - (current_user.prefs.staleness_starts * 3).days
return " stale_l3"
elsif item.created_at < current_user.time - (current_user.prefs.staleness_starts * 2).days
return " stale_l2"
elsif item.created_at < current_user.time - (current_user.prefs.staleness_starts).days
return " stale_l1"
else
return ""
end
end
end