Commit f86f4507 authored by Nikola Milojevic's avatar Nikola Milojevic Committed by Igor Drozdov

Fix cached queries for group_members

Add changelog of performance improvement
parent e13e13c0
- add_to_breadcrumbs _("Groups"), admin_groups_path - add_to_breadcrumbs _("Groups"), admin_groups_path
- breadcrumb_title @group.name - breadcrumb_title @group.name
- page_title @group.name, _("Groups") - page_title @group.name, _("Groups")
- current_user_is_group_owner = @group && @group.has_owner?(current_user)
.js-remove-member-modal .js-remove-member-modal
%h3.page-title %h3.page-title
...@@ -116,7 +117,7 @@ ...@@ -116,7 +117,7 @@
= select_tag :access_level, options_for_select(@group.access_level_roles), class: "project-access-select select2" = select_tag :access_level, options_for_select(@group.access_level_roles), class: "project-access-select select2"
%hr %hr
= button_tag _('Add users to group'), class: "gl-button btn btn-success" = button_tag _('Add users to group'), class: "gl-button btn btn-success"
= render 'shared/members/requests', membership_source: @group, requesters: @requesters, force_mobile_view: true = render 'shared/members/requests', membership_source: @group, group: @group, requesters: @requesters, force_mobile_view: true
.card .card
.card-header .card-header
...@@ -127,6 +128,11 @@ ...@@ -127,6 +128,11 @@
= sprite_icon('pencil-square', css_class: 'gl-icon') = sprite_icon('pencil-square', css_class: 'gl-icon')
= _('Manage access') = _('Manage access')
%ul.content-list.group-users-list.content-list.members-list %ul.content-list.group-users-list.content-list.members-list
= render partial: 'shared/members/member', collection: @members, as: :member, locals: { show_controls: false } = render partial: 'shared/members/member',
collection: @members, as: :member,
locals: { membership_source: @group,
group: @group,
show_controls: false,
current_user_is_group_owner: current_user_is_group_owner }
.card-footer .card-footer
= paginate @members, param_name: 'members_page', theme: 'gitlab' = paginate @members, param_name: 'members_page', theme: 'gitlab'
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
- breadcrumb_title @project.full_name - breadcrumb_title @project.full_name
- page_title @project.full_name, _("Projects") - page_title @project.full_name, _("Projects")
- @content_class = "admin-projects" - @content_class = "admin-projects"
- current_user_is_group_owner = @group && @group.has_owner?(current_user)
.js-remove-member-modal .js-remove-member-modal
%h3.page-title %h3.page-title
...@@ -183,11 +184,16 @@ ...@@ -183,11 +184,16 @@
= sprite_icon('pencil-square', css_class: 'gl-icon') = sprite_icon('pencil-square', css_class: 'gl-icon')
= _('Manage access') = _('Manage access')
%ul.content-list.members-list %ul.content-list.members-list
= render partial: 'shared/members/member', collection: @group_members, as: :member, locals: { show_controls: false } = render partial: 'shared/members/member',
collection: @group_members, as: :member,
locals: { membership_source: @project,
group: @group,
show_controls: false,
current_user_is_group_owner: current_user_is_group_owner }
.card-footer .card-footer
= paginate @group_members, param_name: 'group_members_page', theme: 'gitlab' = paginate @group_members, param_name: 'group_members_page', theme: 'gitlab'
= render 'shared/members/requests', membership_source: @project, requesters: @requesters, force_mobile_view: true = render 'shared/members/requests', membership_source: @project, group: @group, requesters: @requesters, force_mobile_view: true
.card .card
.card-header .card-header
...@@ -199,6 +205,11 @@ ...@@ -199,6 +205,11 @@
= sprite_icon('pencil-square', css_class: 'gl-icon') = sprite_icon('pencil-square', css_class: 'gl-icon')
= _('Manage access') = _('Manage access')
%ul.content-list.project_members.members-list %ul.content-list.project_members.members-list
= render partial: 'shared/members/member', collection: @project_members, as: :member, locals: { show_controls: false } = render partial: 'shared/members/member',
collection: @project_members, as: :member,
locals: { membership_source: @project,
group: @group,
show_controls: false,
current_user_is_group_owner: current_user_is_group_owner }
.card-footer .card-footer
= paginate @project_members, param_name: 'project_members_page', theme: 'gitlab' = paginate @project_members, param_name: 'project_members_page', theme: 'gitlab'
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- show_access_requests = can_manage_members && @requesters.exists? - show_access_requests = can_manage_members && @requesters.exists?
- invited_active = params[:search_invited].present? || params[:invited_members_page].present? - invited_active = params[:search_invited].present? || params[:invited_members_page].present?
- vue_members_list_enabled = Feature.enabled?(:vue_group_members_list, @group) - vue_members_list_enabled = Feature.enabled?(:vue_group_members_list, @group)
- current_user_is_group_owner = @group && @group.has_owner?(current_user)
- form_item_label_css_class = 'label-bold gl-mr-2 gl-mb-0 gl-py-2 align-self-md-center' - form_item_label_css_class = 'label-bold gl-mr-2 gl-mb-0 gl-py-2 align-self-md-center'
...@@ -71,7 +72,11 @@ ...@@ -71,7 +72,11 @@
.js-group-members-list{ data: group_members_list_data_attributes(@group, @members) } .js-group-members-list{ data: group_members_list_data_attributes(@group, @members) }
- else - else
%ul.content-list.members-list{ data: { qa_selector: 'members_list' } } %ul.content-list.members-list{ data: { qa_selector: 'members_list' } }
= render partial: 'shared/members/member', collection: @members, as: :member = render partial: 'shared/members/member',
collection: @members, as: :member,
locals: { membership_source: @group,
group: @group,
current_user_is_group_owner: current_user_is_group_owner }
= paginate @members, theme: 'gitlab', params: { invited_members_page: nil, search_invited: nil } = paginate @members, theme: 'gitlab', params: { invited_members_page: nil, search_invited: nil }
- if @group.shared_with_group_links.any? - if @group.shared_with_group_links.any?
#tab-groups.tab-pane #tab-groups.tab-pane
...@@ -97,7 +102,11 @@ ...@@ -97,7 +102,11 @@
.js-group-invited-members-list{ data: group_members_list_data_attributes(@group, @invited_members) } .js-group-invited-members-list{ data: group_members_list_data_attributes(@group, @invited_members) }
- else - else
%ul.content-list.members-list %ul.content-list.members-list
= render partial: 'shared/members/member', collection: @invited_members, as: :member = render partial: 'shared/members/member',
collection: @invited_members, as: :member,
locals: { membership_source: @group,
group: @group,
current_user_is_group_owner: current_user_is_group_owner }
= paginate @invited_members, param_name: 'invited_members_page', theme: 'gitlab', params: { page: nil } = paginate @invited_members, param_name: 'invited_members_page', theme: 'gitlab', params: { page: nil }
- if show_access_requests - if show_access_requests
#tab-access-requests.tab-pane #tab-access-requests.tab-pane
...@@ -109,4 +118,8 @@ ...@@ -109,4 +118,8 @@
.js-group-access-requests-list{ data: group_members_list_data_attributes(@group, @requesters) } .js-group-access-requests-list{ data: group_members_list_data_attributes(@group, @requesters) }
- else - else
%ul.content-list.members-list %ul.content-list.members-list
= render partial: 'shared/members/member', collection: @requesters, as: :member = render partial: 'shared/members/member',
collection: @requesters, as: :member,
locals: { membership_source: @group,
group: @group,
current_user_is_group_owner: current_user_is_group_owner }
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
- members = local_assigns.fetch(:members) - members = local_assigns.fetch(:members)
- group = local_assigns.fetch(:group)
- current_user_is_group_owner = group && group.has_owner?(current_user)
.card .card
.card-header.flex-project-members-panel .card-header.flex-project-members-panel
...@@ -15,4 +17,8 @@ ...@@ -15,4 +17,8 @@
= label_tag :sort_by, _('Sort by'), class: 'col-form-label label-bold px-2' = label_tag :sort_by, _('Sort by'), class: 'col-form-label label-bold px-2'
= render 'shared/members/sort_dropdown' = render 'shared/members/sort_dropdown'
%ul.content-list.members-list{ data: { qa_selector: 'members_list' } } %ul.content-list.members-list{ data: { qa_selector: 'members_list' } }
= render partial: 'shared/members/member', collection: members, as: :member = render partial: 'shared/members/member',
collection: members, as: :member,
locals: { membership_source: project,
group: group,
current_user_is_group_owner: current_user_is_group_owner }
- page_title _("Members") - page_title _("Members")
- can_admin_project_members = can?(current_user, :admin_project_member, @project) - can_admin_project_members = can?(current_user, :admin_project_member, @project)
- group = @project.group
.js-remove-member-modal .js-remove-member-modal
.row.gl-mt-3 .row.gl-mt-3
...@@ -32,12 +33,12 @@ ...@@ -32,12 +33,12 @@
- elsif @project.allowed_to_share_with_group? - elsif @project.allowed_to_share_with_group?
.invite-group= render 'shared/members/invite_group', access_levels: ProjectGroupLink.access_options, default_access_level: ProjectGroupLink.default_access, submit_url: project_group_links_path(@project), group_link_field: 'link_group_id', group_access_field: 'link_group_access' .invite-group= render 'shared/members/invite_group', access_levels: ProjectGroupLink.access_options, default_access_level: ProjectGroupLink.default_access, submit_url: project_group_links_path(@project), group_link_field: 'link_group_id', group_access_field: 'link_group_access'
= render 'shared/members/requests', membership_source: @project, requesters: @requesters = render 'shared/members/requests', membership_source: @project, group: group, requesters: @requesters
.clearfix .clearfix
%h5.member.existing-title %h5.member.existing-title
= _("Existing members and groups") = _("Existing members and groups")
- if @group_links.any? - if @group_links.any?
= render 'projects/project_members/groups', group_links: @group_links = render 'projects/project_members/groups', group_links: @group_links
= render 'projects/project_members/team', project: @project, members: @project_members = render 'projects/project_members/team', project: @project, group: group, members: @project_members
= paginate @project_members, theme: "gitlab" = paginate @project_members, theme: "gitlab"
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
- show_controls = local_assigns.fetch(:show_controls, true) - show_controls = local_assigns.fetch(:show_controls, true)
- force_mobile_view = local_assigns.fetch(:force_mobile_view, false) - force_mobile_view = local_assigns.fetch(:force_mobile_view, false)
- member = local_assigns.fetch(:member) - member = local_assigns.fetch(:member)
- current_user_is_group_owner = local_assigns.fetch(:current_user_is_group_owner, false)
- membership_source = local_assigns.fetch(:membership_source)
- group = local_assigns.fetch(:group)
- user = local_assigns.fetch(:user, member.user) - user = local_assigns.fetch(:user, member.user)
- source = member.source - source = member.source
- override = member.try(:override) - override = member.try(:override)
...@@ -25,13 +28,13 @@ ...@@ -25,13 +28,13 @@
= render 'shared/members/its_you_badge', user: user, current_user: current_user = render 'shared/members/its_you_badge', user: user, current_user: current_user
= render_if_exists 'shared/members/ee/license_badge', user: user, group: @group = render_if_exists 'shared/members/ee/license_badge', user: user, group: group, current_user_is_group_owner: current_user_is_group_owner
= render 'shared/members/blocked_badge', user: user = render 'shared/members/blocked_badge', user: user
= render 'shared/members/two_factor_auth_badge', user: user = render 'shared/members/two_factor_auth_badge', user: user
- if source.instance_of?(Group) && source != @group - if source.instance_of?(Group) && source != membership_source
· ·
= link_to source.full_name, source, class: "gl-display-inline-block inline-link" = link_to source.full_name, source, class: "gl-display-inline-block inline-link"
...@@ -57,10 +60,9 @@ ...@@ -57,10 +60,9 @@
= link_to member.created_by.name, user_path(member.created_by) = link_to member.created_by.name, user_path(member.created_by)
= time_ago_with_tooltip(member.created_at) = time_ago_with_tooltip(member.created_at)
- if show_roles - if show_roles
- current_resource = @project || @group
.controls.member-controls.align-items-center .controls.member-controls.align-items-center
= render_if_exists 'shared/members/ee/ldap_tag', can_override: member.can_override? = render_if_exists 'shared/members/ee/ldap_tag', can_override: member.can_override?
- if show_controls && member.source == current_resource - if show_controls && member.source == membership_source
- if member.can_resend_invite? - if member.can_resend_invite?
= link_to sprite_icon('paper-airplane'), polymorphic_path([:resend_invite, member]), = link_to sprite_icon('paper-airplane'), polymorphic_path([:resend_invite, member]),
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
class: ("is-active" if member.access_level == role_id), class: ("is-active" if member.access_level == role_id),
data: { id: role_id, el_id: dom_id(member), qa_selector: "#{role.downcase}_access_level_link" } data: { id: role_id, el_id: dom_id(member), qa_selector: "#{role.downcase}_access_level_link" }
= render_if_exists 'shared/members/ee/revert_ldap_group_sync_option', = render_if_exists 'shared/members/ee/revert_ldap_group_sync_option',
group: @group, group: group,
member: member, member: member,
can_override: member.can_override? can_override: member.can_override?
.clearable-input.member-form-control{ class: [("d-sm-inline-block" unless force_mobile_view)] } .clearable-input.member-form-control{ class: [("d-sm-inline-block" unless force_mobile_view)] }
...@@ -125,8 +127,8 @@ ...@@ -125,8 +127,8 @@
= _("Delete") = _("Delete")
- unless force_mobile_view - unless force_mobile_view
= sprite_icon('remove', css_class: 'd-none d-sm-block gl-icon') = sprite_icon('remove', css_class: 'd-none d-sm-block gl-icon')
= render_if_exists 'shared/members/ee/override_member_buttons', group: @group, member: member, user: user, action: :edit, can_override: member.can_override? = render_if_exists 'shared/members/ee/override_member_buttons', group: group, member: member, user: user, action: :edit, can_override: member.can_override?
- else - else
%span.member-access-text.user-access-role= member.human_access %span.member-access-text.user-access-role= member.human_access
= render_if_exists 'shared/members/ee/override_member_buttons', group: @group, member: member, user: user, action: :confirm, can_override: member.can_override? = render_if_exists 'shared/members/ee/override_member_buttons', group: group, member: member, user: user, action: :confirm, can_override: member.can_override?
- membership_source = local_assigns.fetch(:membership_source) - membership_source = local_assigns.fetch(:membership_source)
- requesters = local_assigns.fetch(:requesters) - requesters = local_assigns.fetch(:requesters)
- force_mobile_view = local_assigns.fetch(:force_mobile_view, false) - force_mobile_view = local_assigns.fetch(:force_mobile_view, false)
- group = local_assigns.fetch(:group)
- current_user_is_group_owner = group && group.has_owner?(current_user)
- return if requesters.empty? - return if requesters.empty?
...@@ -10,4 +12,9 @@ ...@@ -10,4 +12,9 @@
%strong= membership_source.name %strong= membership_source.name
%span.badge.badge-pill= requesters.size %span.badge.badge-pill= requesters.size
%ul.content-list.members-list %ul.content-list.members-list
= render partial: 'shared/members/member', collection: requesters, as: :member, locals: { force_mobile_view: force_mobile_view } = render partial: 'shared/members/member',
collection: requesters, as: :member,
locals: { membership_source: membership_source,
group: group,
force_mobile_view: force_mobile_view,
current_user_is_group_owner: current_user_is_group_owner }
- if group.present? && group.has_owner?(current_user) && user.using_gitlab_com_seat?(group) - if group.present? && current_user_is_group_owner && user.using_gitlab_com_seat?(group)
= render 'shared/members/badge', type: 'light' do = render 'shared/members/badge', type: 'light' do
= _("Is using seat") = _("Is using seat")
---
title: Fix cached queries for Groups::GroupMembersController#index
merge_request: 44626
author:
type: performance
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