summaryrefslogtreecommitdiff
path: root/app/models/milestone.rb
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-02-25 15:23:34 -0500
committerRubén Dávila <rdavila84@gmail.com>2016-03-01 19:40:50 -0500
commit77731802199f0af523745572720bdbacdb57e804 (patch)
treee5d49ab2ff124dedac8640d7e7c5f724f66f955b /app/models/milestone.rb
parent6aa50165b0acc355925e271f07ef8e87291e0232 (diff)
downloadgitlab-ce-77731802199f0af523745572720bdbacdb57e804.tar.gz
Show days remaining instead of elapsed time for Milestone.
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r--app/models/milestone.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 8f99e3bef9b..3df9a979161 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -110,17 +110,11 @@ class Milestone < ActiveRecord::Base
0
end
- # Returns the elapsed time (in percent) since the Milestone creation date until today.
- # If the Milestone doesn't have a due_date then returns 0 since we can't calculate the elapsed time.
- # If the Milestone is overdue then it returns 100%.
- def percent_time_used
- return 0 unless due_date
- return 100 if expired?
+ def remaining_days
+ return nil if due_date.nil?
+ return 0 if due_date < Date.today
- duration = ((created_at - due_date.to_datetime) / 1.day)
- days_elapsed = ((created_at - Time.now) / 1.day)
-
- ((days_elapsed.to_f / duration) * 100).floor
+ (due_date - Date.today).to_i
end
def expires_at