From 1162f8d77eda707269ce3214ade25bf1c64d304b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Tue, 26 Jan 2016 10:58:04 -0500 Subject: [PATCH] Add elpased time. --- app/assets/stylesheets/pages/milestone.scss | 4 ++++ app/models/milestone.rb | 9 +++++++++ app/views/projects/milestones/show.html.haml | 3 +++ 3 files changed, 16 insertions(+) diff --git a/app/assets/stylesheets/pages/milestone.scss b/app/assets/stylesheets/pages/milestone.scss index e80dc9e84a1..8772de5f1fe 100644 --- a/app/assets/stylesheets/pages/milestone.scss +++ b/app/assets/stylesheets/pages/milestone.scss @@ -11,3 +11,7 @@ li.milestone { height: 6px; } } + +.time-elapsed { + color: #F14539; +} 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? diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index 72a4164d2d4..17429cf3ddd 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -57,6 +57,9 @@ closed %strong== #{@milestone.percent_complete}% complete + %span.time-elapsed + %strong== #{@milestone.percent_time_used}% + time elapsed %span.pull-right= @milestone.expires_at = milestone_progress_bar(@milestone)