diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-01-26 10:58:04 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-02-02 17:45:42 -0500 |
commit | 1162f8d77eda707269ce3214ade25bf1c64d304b (patch) | |
tree | 08b3dc73db9aefe5c1eb85ac1be7702c0b24070c /app/models/milestone.rb | |
parent | 4e8266e8df3a5a66a2622e4c5e1ee902cf3a66b5 (diff) | |
download | gitlab-ce-1162f8d77eda707269ce3214ade25bf1c64d304b.tar.gz |
Add elpased time.
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r-- | app/models/milestone.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 7dba17726c0..21a3ab5227f 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -110,6 +110,15 @@ class Milestone < ActiveRecord::Base 0 end + def percent_time_used + return 100 if expired? + + duration = ((created_at - due_date.to_datetime) / 1.day) + days_elapsed = ((created_at - Time.now) / 1.day) + + ((days_elapsed.to_f / duration) * 100).floor + end + def expires_at if due_date if due_date.past? |