Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
03d58f56
Commit
03d58f56
authored
Mar 01, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Little refactor for milestone_remaining_days helper from last code review.
parent
77731802
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+3
-4
app/models/milestone.rb
app/models/milestone.rb
+1
-2
No files found.
app/helpers/milestones_helper.rb
View file @
03d58f56
...
@@ -38,11 +38,10 @@ module MilestonesHelper
...
@@ -38,11 +38,10 @@ module MilestonesHelper
end
end
def
milestone_remaining_days
(
milestone
)
def
milestone_remaining_days
(
milestone
)
days
=
milestone
.
remaining_days
if
milestone
.
expired?
if
days
==
0
content_tag
(
:strong
,
'expired'
)
content_tag
(
:strong
,
'expired'
)
elsif
days
.
to_i
>
0
elsif
milestone
.
due_date
days
=
milestone
.
remaining_days
content
=
content_tag
(
:strong
,
days
)
content
=
content_tag
(
:strong
,
days
)
content
<<
"
#{
'day'
.
pluralize
(
days
)
}
remaining"
content
<<
"
#{
'day'
.
pluralize
(
days
)
}
remaining"
end
end
...
...
app/models/milestone.rb
View file @
03d58f56
...
@@ -111,8 +111,7 @@ class Milestone < ActiveRecord::Base
...
@@ -111,8 +111,7 @@ class Milestone < ActiveRecord::Base
end
end
def
remaining_days
def
remaining_days
return
nil
if
due_date
.
nil?
return
0
if
!
due_date
||
expired?
return
0
if
due_date
<
Date
.
today
(
due_date
-
Date
.
today
).
to_i
(
due_date
-
Date
.
today
).
to_i
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment