tracks/lib/staleness.rb
Matt Rogers 43275e064e Refactor the calculation for staleness
Provide the number of days that the todo was stale instead of a class
name to use in the view.

We'll use the number of days stale in the helper to determine the class
name
2013-03-10 13:46:22 -05:00

10 lines
234 B
Ruby

require 'active_support/all'
class Staleness
SECONDS_PER_DAY = 86400
def self.days_stale(item, current_user)
return 0 if item.due || item.completed?
(current_user.time - item.created_at).to_i / SECONDS_PER_DAY
end
end