debian-mirror-gitlab/app/models/concerns/milestoneish.rb

30 lines
692 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
module Milestoneish
2017-01-15 13:20:01 +05:30
def closed_items_count(user)
2016-06-02 11:05:42 +05:30
issues_visible_to_user(user).closed.size + merge_requests.closed_and_merged.size
end
2017-01-15 13:20:01 +05:30
def total_items_count(user)
2016-06-02 11:05:42 +05:30
issues_visible_to_user(user).size + merge_requests.size
end
2017-01-15 13:20:01 +05:30
def complete?(user)
2016-06-02 11:05:42 +05:30
total_items_count(user) > 0 && total_items_count(user) == closed_items_count(user)
end
2017-01-15 13:20:01 +05:30
def percent_complete(user)
2016-06-02 11:05:42 +05:30
((closed_items_count(user) * 100) / total_items_count(user)).abs
rescue ZeroDivisionError
0
end
def remaining_days
return 0 if !due_date || expired?
(due_date - Date.today).to_i
end
2017-01-15 13:20:01 +05:30
def issues_visible_to_user(user)
IssuesFinder.new(user).execute.where(id: issues)
2016-06-02 11:05:42 +05:30
end
end