Skip to content
代码片段 群组 项目
提交 ae8160de 编辑于 作者: Felipe Artur's avatar Felipe Artur
浏览文件

Add direct members metric to VSD counts

Persist direct group members count on database,
this will later be used on Value Streams Dashboard.

EE: true
Changelog: added
上级 56dcfdf5
No related branches found
No related tags found
无相关合并请求
...@@ -14,7 +14,7 @@ class Count < ApplicationRecord ...@@ -14,7 +14,7 @@ class Count < ApplicationRecord
validates :namespace_id, :count, :metric, :recorded_at, presence: true validates :namespace_id, :count, :metric, :recorded_at, presence: true
enum metric: { projects: 1, issues: 2, groups: 3, merge_requests: 4, pipelines: 5 } enum metric: { projects: 1, issues: 2, groups: 3, merge_requests: 4, pipelines: 5, direct_members: 6 }
scope :latest_first_order, -> { order(recorded_at: :desc, id: :desc) } scope :latest_first_order, -> { order(recorded_at: :desc, id: :desc) }
scope :for_period, ->(metric, from, to) { scope :for_period, ->(metric, from, to) {
......
...@@ -69,6 +69,13 @@ class TopLevelGroupCounterService ...@@ -69,6 +69,13 @@ class TopLevelGroupCounterService
inner_namespace_query: PROJECT_SELECT_SCOPE, inner_namespace_query: PROJECT_SELECT_SCOPE,
count_batching_column: :id, count_batching_column: :id,
count_scope: ->(namespace) { Ci::Pipeline.where(project_id: namespace.tmp_project_id) } count_scope: ->(namespace) { Ci::Pipeline.where(project_id: namespace.tmp_project_id) }
}.freeze,
direct_members: {
metric: ::Analytics::ValueStreamDashboard::Count.metrics[:direct_members],
namespace_class: Group,
inner_namespace_query: GROUP_SELECT_SCOPE,
count_batching_column: :id,
count_scope: ->(namespace) { GroupMember.non_invite.non_request.where(source_id: namespace.id) }
}.freeze }.freeze
}.freeze }.freeze
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -13,15 +13,6 @@ ...@@ -13,15 +13,6 @@
let_it_be(:project_in_subsubgroup) { create(:project, group: subsubgroup) } let_it_be(:project_in_subsubgroup) { create(:project, group: subsubgroup) }
let_it_be(:issue_in_group) { create(:issue, project: project_in_group) } let_it_be(:issue_in_group) { create(:issue, project: project_in_group) }
let_it_be(:another_issue_in_group) { create(:issue, project: project_in_group) }
let_it_be(:issue_in_subsubgroup) { create(:issue, project: project_in_subsubgroup) }
let_it_be(:mr_in_subsubgroup1) { create(:merge_request, :unique_branches, source_project: project_in_subsubgroup) }
let_it_be(:mr_in_subsubgroup2) { create(:merge_request, :unique_branches, source_project: project_in_subsubgroup) }
let_it_be(:ci_pipeline1) { create(:ci_pipeline, project: project_in_group) }
let_it_be(:ci_pipeline2) { create(:ci_pipeline, project: project_in_group) }
let_it_be(:ci_pipeline3) { create(:ci_pipeline, project: project_in_group) }
let_it_be(:aggregation) { create(:value_stream_dashboard_aggregation, namespace: group, last_run_at: nil) } let_it_be(:aggregation) { create(:value_stream_dashboard_aggregation, namespace: group, last_run_at: nil) }
...@@ -56,7 +47,10 @@ ...@@ -56,7 +47,10 @@
{ metric: 'pipelines', namespace_id: project_in_group.project_namespace.id, count: 3 }, { metric: 'pipelines', namespace_id: project_in_group.project_namespace.id, count: 3 },
{ metric: 'pipelines', namespace_id: project_in_subgroup.project_namespace.id, count: 0 }, { metric: 'pipelines', namespace_id: project_in_subgroup.project_namespace.id, count: 0 },
{ metric: 'pipelines', namespace_id: another_project_in_subgroup.project_namespace.id, count: 0 }, { metric: 'pipelines', namespace_id: another_project_in_subgroup.project_namespace.id, count: 0 },
{ metric: 'pipelines', namespace_id: project_in_subsubgroup.project_namespace.id, count: 0 } { metric: 'pipelines', namespace_id: project_in_subsubgroup.project_namespace.id, count: 0 },
{ metric: 'direct_members', namespace_id: group.id, count: 1 },
{ metric: 'direct_members', namespace_id: subgroup.id, count: 2 },
{ metric: 'direct_members', namespace_id: subsubgroup.id, count: 0 }
] ]
end end
...@@ -66,6 +60,25 @@ ...@@ -66,6 +60,25 @@
.order(:namespace_id) .order(:namespace_id)
end end
before_all do
# Issues
create(:issue, project: project_in_group)
create(:issue, project: project_in_subsubgroup)
# Group members
create(:group_member, group: group)
create(:group_member, :access_request, group: group) # Not included
create(:group_member, :invited, :developer, group: group) # Not included
create(:group_member, group: subgroup)
create(:group_member, group: subgroup)
# Merge Requests
create(:merge_request, :unique_branches, source_project: project_in_subsubgroup)
create(:merge_request, :unique_branches, source_project: project_in_subsubgroup)
# Pipelines
create(:ci_pipeline, project: project_in_group)
create(:ci_pipeline, project: project_in_group)
create(:ci_pipeline, project: project_in_group)
end
it 'returns successful response' do it 'returns successful response' do
service_response = run_service service_response = run_service
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册