diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-15 20:48:30 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-23 14:41:04 +0300 |
commit | 3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9 (patch) | |
tree | 45314bfcb16ba7095e209d3a1f3eb9be2016b2a6 /app/models/concerns/milestoneish.rb | |
parent | d7eeb6df51ffe2ad864ef49d0e465b88ab158520 (diff) |
Add a starting date to milestones
Diffstat (limited to 'app/models/concerns/milestoneish.rb')
-rw-r--r-- | app/models/concerns/milestoneish.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index 7bcc78247ba..e65fc9eaa09 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -23,7 +23,31 @@ module Milestoneish (due_date - Date.today).to_i end + def elapsed_days + return 0 if !start_date || start_date.future? + + (Date.today - start_date).to_i + end + def issues_visible_to_user(user = nil) issues.visible_to_user(user) end + + def upcoming? + start_date && start_date.future? + end + + def expires_at + if due_date + if due_date.past? + "expired on #{due_date.to_s(:medium)}" + else + "expires on #{due_date.to_s(:medium)}" + end + end + end + + def expired? + due_date && due_date.past? + end end |