diff --git a/app/models/users_statistics.rb b/app/models/users_statistics.rb index a314ae8920bcc5214c244379d9ae797488c3d481..6b2261a0591aa4f8b6c5b9e8d8e9f90bf77bbbd7 100644 --- a/app/models/users_statistics.rb +++ b/app/models/users_statistics.rb @@ -7,6 +7,7 @@ def active [ without_groups_and_projects, with_highest_role_guest, + with_highest_role_planner, with_highest_role_reporter, with_highest_role_developer, with_highest_role_maintainer, @@ -34,6 +35,7 @@ def highest_role_stats { without_groups_and_projects: without_groups_and_projects_stats, with_highest_role_guest: batch_count_for_access_level(Gitlab::Access::GUEST), + with_highest_role_planner: batch_count_for_access_level(Gitlab::Access::PLANNER), with_highest_role_reporter: batch_count_for_access_level(Gitlab::Access::REPORTER), with_highest_role_developer: batch_count_for_access_level(Gitlab::Access::DEVELOPER), with_highest_role_maintainer: batch_count_for_access_level(Gitlab::Access::MAINTAINER), diff --git a/app/views/admin/dashboard/_stats_users_table.html.haml b/app/views/admin/dashboard/_stats_users_table.html.haml index 218f91fd3a6bcd8059150f3c3684d29b567de944..32c444ac7003117a6364f246dbcdd466e606a390 100644 --- a/app/views/admin/dashboard/_stats_users_table.html.haml +++ b/app/views/admin/dashboard/_stats_users_table.html.haml @@ -6,6 +6,13 @@ %td.gl-text-right{ class: '!gl-p-5' } = @users_statistics&.without_groups_and_projects = render_if_exists 'admin/dashboard/minimal_access_stats_row', users_statistics: @users_statistics + %tr + %td{ class: '!gl-p-5' } + = s_('AdminArea|Users with highest role') + %strong + = s_('AdminArea|Planner') + %td.gl-text-right{ class: '!gl-p-5' } + = @users_statistics&.with_highest_role_planner %tr %td{ class: '!gl-p-5' } = s_('AdminArea|Users with highest role') diff --git a/db/migrate/20241029130136_add_with_highest_role_planner_to_users_statistics.rb b/db/migrate/20241029130136_add_with_highest_role_planner_to_users_statistics.rb new file mode 100644 index 0000000000000000000000000000000000000000..b208b69374659af00270d2cecba12f068ae1b9d2 --- /dev/null +++ b/db/migrate/20241029130136_add_with_highest_role_planner_to_users_statistics.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddWithHighestRolePlannerToUsersStatistics < Gitlab::Database::Migration[2.2] + milestone '17.7' + + def change + add_column :users_statistics, :with_highest_role_planner, :integer, default: 0, null: false + end +end diff --git a/db/schema_migrations/20241029130136 b/db/schema_migrations/20241029130136 new file mode 100644 index 0000000000000000000000000000000000000000..7b372520ca7f39e22ec3bce9a6d6b1ac8da226b8 --- /dev/null +++ b/db/schema_migrations/20241029130136 @@ -0,0 +1 @@ +fdbb03606a5f6f61031e54b407ee60f5074d5130bf856959a0f3b010d5413654 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 6fdd10467b7ba13008516ca8601b1e6bdc644971..590204bc3a2bc9d456a91cbdc1647effaceb5b1a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -21060,7 +21060,8 @@ CREATE TABLE users_statistics ( bots integer DEFAULT 0 NOT NULL, blocked integer DEFAULT 0 NOT NULL, with_highest_role_minimal_access integer DEFAULT 0 NOT NULL, - with_highest_role_guest_with_custom_role integer DEFAULT 0 NOT NULL + with_highest_role_guest_with_custom_role integer DEFAULT 0 NOT NULL, + with_highest_role_planner integer DEFAULT 0 NOT NULL ); CREATE SEQUENCE users_statistics_id_seq diff --git a/ee/app/models/ee/users_statistics.rb b/ee/app/models/ee/users_statistics.rb index 140cc774e90f762d2761961fd93d8d9dd181ad78..e3513095452d4d19289ab4d3840603fd003bd698 100644 --- a/ee/app/models/ee/users_statistics.rb +++ b/ee/app/models/ee/users_statistics.rb @@ -32,6 +32,7 @@ def base_non_billable def base_billable_users [ + with_highest_role_planner, with_highest_role_reporter, with_highest_role_developer, with_highest_role_maintainer, diff --git a/ee/app/views/admin/dashboard/_stats_users_table.html.haml b/ee/app/views/admin/dashboard/_stats_users_table.html.haml index eb1b0459e2223ecaedf25eb15039555f5517756e..0ae710d2c9cd27ba91f9ce794153a909249a2f96 100644 --- a/ee/app/views/admin/dashboard/_stats_users_table.html.haml +++ b/ee/app/views/admin/dashboard/_stats_users_table.html.haml @@ -7,6 +7,13 @@ = render_if_exists 'admin/dashboard/without_group_or_project_row', users_statistics: @users_statistics unless exclude_guests_from_active_count = render_if_exists 'admin/dashboard/minimal_access_stats_row', users_statistics: @users_statistics = render_if_exists 'admin/dashboard/elevated_role_stats_row', users_statistics: @users_statistics + %tr + %td{ class: '!gl-p-5' } + = s_('AdminArea|Users with highest role') + %strong + = s_('AdminArea|Planner') + %td.gl-text-right{ class: '!gl-p-5' } + = @users_statistics&.with_highest_role_planner %tr %td{ class: '!gl-p-5' } = s_('AdminArea|Users with highest role') diff --git a/ee/spec/features/admin/admin_dashboard_spec.rb b/ee/spec/features/admin/admin_dashboard_spec.rb index 43525023b3ca3eec43860c4a05bd899c705fd9a0..4afc70da1ea42378fcb474c9d264bead94537509 100644 --- a/ee/spec/features/admin/admin_dashboard_spec.rb +++ b/ee/spec/features/admin/admin_dashboard_spec.rb @@ -61,15 +61,16 @@ expect(page).to have_content("Users without a Group and Project 23") expect(page).to have_content("Users with highest role Guest 5") + expect(page).to have_content("Users with highest role Planner 7") expect(page).to have_content("Users with highest role Reporter 9") expect(page).to have_content("Users with highest role Developer 21") expect(page).to have_content("Users with highest role Maintainer 6") expect(page).to have_content("Users with highest role Owner 5") expect(page).to have_content("Bots 2") - expect(page).to have_content("Billable users 69") - expect(page).to have_content("Active users (total billable + total non-billable) 71") + expect(page).to have_content("Billable users 76") + expect(page).to have_content("Active users (total billable + total non-billable) 78") expect(page).to have_content("Blocked users 7") - expect(page).to have_content("Total users (active users + blocked users) 78") + expect(page).to have_content("Total users (active users + blocked users) 85") end end diff --git a/ee/spec/models/ee/users_statistics_spec.rb b/ee/spec/models/ee/users_statistics_spec.rb index b111c5ade1f450c90801ffb94371e575618aeb52..84435d686fc52213227292048279d6be975b5a49 100644 --- a/ee/spec/models/ee/users_statistics_spec.rb +++ b/ee/spec/models/ee/users_statistics_spec.rb @@ -9,7 +9,7 @@ describe '#billable' do it 'sums users statistics values excluding blocked users and bots' do - expect(users_statistics.billable).to eq(74) + expect(users_statistics.billable).to eq(81) end context 'when there is an ultimate license' do @@ -18,14 +18,14 @@ end it 'excludes blocked users, bots, guest users, users without a group or project and minimal access users' do - expect(users_statistics.billable).to eq(43) + expect(users_statistics.billable).to eq(50) end end end describe '#active' do it 'includes minimal access roles' do - expect(users_statistics.active).to eq(76) + expect(users_statistics.active).to eq(83) end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7b46ee6a2156a73d27f9bcd7b12f4d30299dd8cd..68bb8e12c437236e0cbbbbb7fe5321746cb9be1b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -3758,6 +3758,9 @@ msgstr "" msgid "AdminArea|Owner" msgstr "" +msgid "AdminArea|Planner" +msgstr "" + msgid "AdminArea|Projects" msgstr "" diff --git a/spec/factories/users_statistics.rb b/spec/factories/users_statistics.rb index 07699dc38b2e820ad1d352dbbaf66343416b7bcb..ea53ade722eebe5c8fe86b39f667d0dc0d743165 100644 --- a/spec/factories/users_statistics.rb +++ b/spec/factories/users_statistics.rb @@ -4,6 +4,7 @@ factory :users_statistics do without_groups_and_projects { 23 } with_highest_role_guest { 5 } + with_highest_role_planner { 7 } with_highest_role_reporter { 9 } with_highest_role_developer { 21 } with_highest_role_maintainer { 6 } diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index a7ad3a05c35302f6b8e85304f535480085ec8fd7..67e7cd6dc94c3c92fb247a3cc320fc159bd75fdf 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -36,6 +36,7 @@ expect(page).to have_content('Users without a Group and Project 23') expect(page).to have_content('Users with highest role Guest 5') + expect(page).to have_content('Users with highest role Planner 7') expect(page).to have_content('Users with highest role Reporter 9') expect(page).to have_content('Users with highest role Developer 21') expect(page).to have_content('Users with highest role Maintainer 6') @@ -43,13 +44,13 @@ expect(page).to have_content('Bots 2') if Gitlab.ee? - expect(page).to have_content('Billable users 69') + expect(page).to have_content('Billable users 76') else - expect(page).not_to have_content('Billable users 69') + expect(page).not_to have_content('Billable users 76') end expect(page).to have_content('Blocked users 7') - expect(page).to have_content('Total users (active users + blocked users) 78') + expect(page).to have_content('Total users (active users + blocked users) 85') end end diff --git a/spec/models/users_statistics_spec.rb b/spec/models/users_statistics_spec.rb index d1ca9ff5125258d0ef39b0a977910175541422ea..26630ace9bae209098ff88fadedba4a60fef8b2f 100644 --- a/spec/models/users_statistics_spec.rb +++ b/spec/models/users_statistics_spec.rb @@ -36,6 +36,7 @@ before do create_list(:user_highest_role, 1) create_list(:user_highest_role, 2, :guest) + create_list(:user_highest_role, 2, :planner) create_list(:user_highest_role, 2, :reporter) create_list(:user_highest_role, 2, :developer) create_list(:user_highest_role, 2, :maintainer) @@ -51,6 +52,7 @@ expect(described_class.create_current_stats!).to have_attributes( without_groups_and_projects: 1, with_highest_role_guest: 2, + with_highest_role_planner: 2, with_highest_role_reporter: 2, with_highest_role_developer: 2, with_highest_role_maintainer: 2, @@ -72,13 +74,13 @@ describe '#active' do it 'sums users statistics values without the value for blocked' do - expect(users_statistics.active).to eq(71) + expect(users_statistics.active).to eq(78) end end describe '#total' do it 'sums all users statistics values' do - expect(users_statistics.total).to eq(78) + expect(users_statistics.total).to eq(85) end end end