2016-03-06 23:07:19 -05:00
|
|
|
module Milestoneish
|
2016-03-17 16:59:30 -04:00
|
|
|
def closed_items_count(user = nil)
|
|
|
|
issues_visible_to_user(user).closed.size + merge_requests.closed_and_merged.size
|
2016-03-06 23:07:19 -05:00
|
|
|
end
|
|
|
|
|
2016-03-17 16:59:30 -04:00
|
|
|
def total_items_count(user = nil)
|
|
|
|
issues_visible_to_user(user).size + merge_requests.size
|
2016-03-06 23:07:19 -05:00
|
|
|
end
|
|
|
|
|
2016-03-17 16:59:30 -04:00
|
|
|
def complete?(user = nil)
|
2016-04-26 07:22:52 -04:00
|
|
|
total_items_count(user) > 0 && total_items_count(user) == closed_items_count(user)
|
2016-03-06 23:07:19 -05:00
|
|
|
end
|
|
|
|
|
2016-03-17 16:59:30 -04:00
|
|
|
def percent_complete(user = nil)
|
|
|
|
((closed_items_count(user) * 100) / total_items_count(user)).abs
|
2016-03-06 23:07:19 -05:00
|
|
|
rescue ZeroDivisionError
|
|
|
|
0
|
|
|
|
end
|
|
|
|
|
|
|
|
def remaining_days
|
|
|
|
return 0 if !due_date || expired?
|
|
|
|
|
|
|
|
(due_date - Date.today).to_i
|
|
|
|
end
|
2016-03-17 16:59:30 -04:00
|
|
|
|
|
|
|
def issues_visible_to_user(user = nil)
|
|
|
|
issues.visible_to_user(user)
|
|
|
|
end
|
2016-03-06 23:07:19 -05:00
|
|
|
end
|