Commit 3cd51173 authored by Ronald van Zon's avatar Ronald van Zon Committed by Eagllus

Fixing count on Milestones

By adding groups to milestones we can now include them
in the count of Open and Closed.
parent a5cfacc2
......@@ -12,4 +12,8 @@ class Dashboard::ApplicationController < ApplicationController
def projects
@projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
end
def groups
@groups ||= GroupsFinder.new(current_user, state_all: true).execute
end
end
......@@ -4,12 +4,13 @@ class Dashboard::MilestonesController < Dashboard::ApplicationController
include MilestoneActions
before_action :projects
before_action :groups
before_action :milestone, only: [:show, :merge_requests, :participants, :labels]
def index
respond_to do |format|
format.html do
@milestone_states = GlobalMilestone.states_count(@projects)
@milestone_states = GlobalMilestone.states_count(@projects, @groups)
@milestones = Kaminari.paginate_array(milestones).page(params[:page])
end
format.json do
......
......@@ -34,15 +34,31 @@ class GlobalMilestone
new(title, child_milestones)
end
def self.states_count(projects, group = nil)
def self.states_count(projects, groups = nil)
legacy_group_milestones_count = legacy_group_milestone_states_count(projects)
group_milestones_count = group_milestones_states_count(group)
group_milestones_count = groups_milestone_state_count(groups)
legacy_group_milestones_count.merge(group_milestones_count) do |k, legacy_group_milestones_count, group_milestones_count|
legacy_group_milestones_count + group_milestones_count
end
end
def self.groups_milestone_state_count(groups)
return STATE_COUNT_HASH unless groups
return self.group_milestones_states_count(groups) unless groups.respond_to?(:each)
milestone_states = STATE_COUNT_HASH
groups.each do |group|
group_milestones_count = self.group_milestones_states_count(group)
milestone_states = milestone_states.merge(group_milestones_count) do |k, milestone_state, group_milestones_count|
milestone_state + group_milestones_count
end
end
milestone_states
end
def self.group_milestones_states_count(group)
return STATE_COUNT_HASH unless group
......
---
title: Fixing count on Milestones
merge_request: 21446
author: eagllus
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment