diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-03-06 23:07:19 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-03-06 23:07:19 -0500 |
commit | 95b06a62c0db5f8c285a1d24fa1994e10c70ff27 (patch) | |
tree | 97932d8d2155de4c4d71bba06dff8fe0f7eeb09a /app/models/global_milestone.rb | |
parent | c91554de09cb2b19e1403fdf50f691004e6befdb (diff) | |
download | gitlab-ce-95b06a62c0db5f8c285a1d24fa1994e10c70ff27.tar.gz |
Updates from last code review.issue_13621_2
Diffstat (limited to 'app/models/global_milestone.rb')
-rw-r--r-- | app/models/global_milestone.rb | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index e13aaf16732..97bd79af083 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -1,4 +1,6 @@ class GlobalMilestone + include Milestoneish + attr_accessor :title, :milestones alias_attribute :name, :title @@ -31,32 +33,6 @@ class GlobalMilestone @projects ||= Project.for_milestones(milestones.map(&:id)) end - def issues_count - issues.count - end - - def merge_requests_count - merge_requests.count - end - - def open_items_count - opened_issues.count + opened_merge_requests.count - end - - def closed_items_count - closed_issues.count + closed_merge_requests.count - end - - def total_items_count - issues_count + merge_requests_count - end - - def percent_complete - ((closed_items_count * 100) / total_items_count).abs - rescue ZeroDivisionError - 0 - end - def state state = milestones.map { |milestone| milestone.state } @@ -88,29 +64,8 @@ class GlobalMilestone end def labels - @labels ||= milestones.map do |ms| - ms.labels.map { |label| LabelWithMilestone.new(label, ms) } - end.flatten.sort_by!(&:title) - end - - def opened_issues - issues.opened - end - - def closed_issues - issues.closed - end - - def opened_merge_requests - merge_requests.opened - end - - def closed_merge_requests - merge_requests.with_states(:closed, :merged, :locked) - end - - def complete? - total_items_count == closed_items_count + @labels ||= GlobalLabel.build_collection(milestones.map(&:labels).flatten) + .sort_by!(&:title) end def due_date |