mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-01 14:58:50 +01:00
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.
18 lines
539 B
Ruby
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
|
|
|