Commit a8115b7c authored by Alper Akgun's avatar Alper Akgun

Move plan stage usage activity to CE

Also updates the documentation
parent 7d7596f4
---
title: Move plan stage usage activity to CE
merge_request: 36087
author:
type: changed
...@@ -681,10 +681,19 @@ appear to be associated to any of the services running, since they all appear to ...@@ -681,10 +681,19 @@ appear to be associated to any of the services running, since they all appear to
| `ldap_group_sync_enabled` | `usage_activity_by_stage` | `manage` | | EE | | | `ldap_group_sync_enabled` | `usage_activity_by_stage` | `manage` | | EE | |
| `ldap_admin_sync_enabled` | `usage_activity_by_stage` | `manage` | | EE | | | `ldap_admin_sync_enabled` | `usage_activity_by_stage` | `manage` | | EE | |
| `group_saml_enabled` | `usage_activity_by_stage` | `manage` | | EE | | | `group_saml_enabled` | `usage_activity_by_stage` | `manage` | | EE | |
| `projects_jira_dvcs_server_active` | `usage_activity_by_stage` | `plan` | | | | | `issues` | `usage_activity_by_stage` | `plan` | | CE+EE | |
| `service_desk_enabled_projects` | `usage_activity_by_stage` | `plan` | | | | | `notes` | `usage_activity_by_stage` | `plan` | | CE+EE | |
| `service_desk_issues` | `usage_activity_by_stage` | `plan` | | | | | `projects` | `usage_activity_by_stage` | `plan` | | CE+EE | |
| `todos: 0` | `usage_activity_by_stage` | `plan` | | | | | `todos` | `usage_activity_by_stage` | `plan` | | CE+EE | |
| `assignee_lists` | `usage_activity_by_stage` | `plan` | | EE | |
| `epics` | `usage_activity_by_stage` | `plan` | | EE | |
| `label_lists` | `usage_activity_by_stage` | `plan` | | EE | |
| `milestone_lists` | `usage_activity_by_stage` | `plan` | | EE | |
| `projects_jira_active` | `usage_activity_by_stage` | `plan` | | EE | |
| `projects_jira_dvcs_server_active` | `usage_activity_by_stage` | `plan` | | EE | |
| `projects_jira_dvcs_server_active` | `usage_activity_by_stage` | `plan` | | EE | |
| `service_desk_enabled_projects` | `usage_activity_by_stage` | `plan` | | EE | |
| `service_desk_issues` | `usage_activity_by_stage` | `plan` | | EE | |
| `deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total deployments | | `deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total deployments |
| `failed_deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total failed deployments | | `failed_deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total failed deployments |
| `projects_mirrored_with_pipelines_enabled` | `usage_activity_by_stage` | `release` | | EE | Projects with repository mirroring enabled | | `projects_mirrored_with_pipelines_enabled` | `usage_activity_by_stage` | `release` | | EE | Projects with repository mirroring enabled |
......
...@@ -266,17 +266,13 @@ module EE ...@@ -266,17 +266,13 @@ module EE
super.merge({ super.merge({
assignee_lists: distinct_count(::List.assignee.where(time_period), :user_id), assignee_lists: distinct_count(::List.assignee.where(time_period), :user_id),
epics: distinct_count(::Epic.where(time_period), :author_id), epics: distinct_count(::Epic.where(time_period), :author_id),
issues: distinct_count(::Issue.where(time_period), :author_id),
label_lists: distinct_count(::List.label.where(time_period), :user_id), label_lists: distinct_count(::List.label.where(time_period), :user_id),
milestone_lists: distinct_count(::List.milestone.where(time_period), :user_id), milestone_lists: distinct_count(::List.milestone.where(time_period), :user_id),
notes: distinct_count(::Note.where(time_period), :author_id),
projects: distinct_count(::Project.where(time_period), :creator_id),
projects_jira_active: distinct_count(::Project.with_active_jira_services.where(time_period), :creator_id), projects_jira_active: distinct_count(::Project.with_active_jira_services.where(time_period), :creator_id),
projects_jira_dvcs_cloud_active: distinct_count(::Project.with_active_jira_services.with_jira_dvcs_cloud.where(time_period), :creator_id), projects_jira_dvcs_cloud_active: distinct_count(::Project.with_active_jira_services.with_jira_dvcs_cloud.where(time_period), :creator_id),
projects_jira_dvcs_server_active: distinct_count(::Project.with_active_jira_services.with_jira_dvcs_server.where(time_period), :creator_id), projects_jira_dvcs_server_active: distinct_count(::Project.with_active_jira_services.with_jira_dvcs_server.where(time_period), :creator_id),
service_desk_enabled_projects: distinct_count_service_desk_enabled_projects(time_period), service_desk_enabled_projects: distinct_count_service_desk_enabled_projects(time_period),
service_desk_issues: count(::Issue.service_desk.where(time_period)), service_desk_issues: count(::Issue.service_desk.where(time_period))
todos: distinct_count(::Todo.where(time_period), :author_id)
}) })
end end
......
...@@ -442,48 +442,37 @@ RSpec.describe Gitlab::UsageData do ...@@ -442,48 +442,37 @@ RSpec.describe Gitlab::UsageData do
for_defined_days_back do for_defined_days_back do
user = create(:user) user = create(:user)
project = create(:project, creator: user) project = create(:project, creator: user)
issue = create(:issue, project: project, author: User.support_bot) create(:issue, project: project, author: User.support_bot)
create(:issue, project: project, author: user)
board = create(:board, project: project) board = create(:board, project: project)
create(:user_list, board: board, user: user) create(:user_list, board: board, user: user)
create(:milestone_list, board: board, milestone: create(:milestone, project: project), user: user) create(:milestone_list, board: board, milestone: create(:milestone, project: project), user: user)
create(:list, board: board, label: create(:label, project: project), user: user) create(:list, board: board, label: create(:label, project: project), user: user)
create(:note, project: project, noteable: issue, author: user)
create(:epic, author: user) create(:epic, author: user)
create(:todo, project: project, target: issue, author: user)
create(:jira_service, :jira_cloud_service, active: true, project: create(:project, :jira_dvcs_cloud, creator: user)) create(:jira_service, :jira_cloud_service, active: true, project: create(:project, :jira_dvcs_cloud, creator: user))
create(:jira_service, active: true, project: create(:project, :jira_dvcs_server, creator: user)) create(:jira_service, active: true, project: create(:project, :jira_dvcs_server, creator: user))
end end
expect(described_class.uncached_data[:usage_activity_by_stage][:plan]).to eq( expect(described_class.uncached_data[:usage_activity_by_stage][:plan]).to include(
assignee_lists: 2, assignee_lists: 2,
epics: 2, epics: 2,
issues: 3,
label_lists: 2, label_lists: 2,
milestone_lists: 2, milestone_lists: 2,
notes: 2,
projects: 2,
projects_jira_active: 2, projects_jira_active: 2,
projects_jira_dvcs_cloud_active: 2, projects_jira_dvcs_cloud_active: 2,
projects_jira_dvcs_server_active: 2, projects_jira_dvcs_server_active: 2,
service_desk_enabled_projects: 2, service_desk_enabled_projects: 2,
service_desk_issues: 2, service_desk_issues: 2
todos: 2
) )
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:plan]).to eq( expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:plan]).to include(
assignee_lists: 1, assignee_lists: 1,
epics: 1, epics: 1,
issues: 2,
label_lists: 1, label_lists: 1,
milestone_lists: 1, milestone_lists: 1,
notes: 1,
projects: 1,
projects_jira_active: 1, projects_jira_active: 1,
projects_jira_dvcs_cloud_active: 1, projects_jira_dvcs_cloud_active: 1,
projects_jira_dvcs_server_active: 1, projects_jira_dvcs_server_active: 1,
service_desk_enabled_projects: 1, service_desk_enabled_projects: 1,
service_desk_issues: 1, service_desk_issues: 1
todos: 1
) )
end end
end end
......
...@@ -525,9 +525,16 @@ module Gitlab ...@@ -525,9 +525,16 @@ module Gitlab
# Omitted because no user, creator or author associated: `boards`, `labels`, `milestones`, `uploads` # Omitted because no user, creator or author associated: `boards`, `labels`, `milestones`, `uploads`
# Omitted because too expensive: `epics_deepest_relationship_level` # Omitted because too expensive: `epics_deepest_relationship_level`
# Omitted because of encrypted properties: `projects_jira_cloud_active`, `projects_jira_server_active` # Omitted because of encrypted properties: `projects_jira_cloud_active`, `projects_jira_server_active`
# rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_plan(time_period) def usage_activity_by_stage_plan(time_period)
{} {
issues: distinct_count(::Issue.where(time_period), :author_id),
notes: distinct_count(::Note.where(time_period), :author_id),
projects: distinct_count(::Project.where(time_period), :creator_id),
todos: distinct_count(::Todo.where(time_period), :author_id)
}
end end
# rubocop: enable CodeReuse/ActiveRecord
# Omitted because no user, creator or author associated: `environments`, `feature_flags`, `in_review_folder`, `pages_domains` # Omitted because no user, creator or author associated: `environments`, `feature_flags`, `in_review_folder`, `pages_domains`
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -235,6 +235,31 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -235,6 +235,31 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end end
end end
context 'for plan' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
project = create(:project, creator: user)
issue = create(:issue, project: project, author: user)
create(:note, project: project, noteable: issue, author: user)
create(:todo, project: project, target: issue, author: user)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:plan]).to include(
issues: 2,
notes: 2,
projects: 2,
todos: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:plan]).to include(
issues: 1,
notes: 1,
projects: 1,
todos: 1
)
end
end
context 'for release' do context 'for release' do
it 'includes accurate usage_activity_by_stage data' do it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do for_defined_days_back do
......
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