diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-10 00:10:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-10 00:10:09 +0000 |
commit | 26774b8d98581b2f211cd5cf04dcec0e352c04a6 (patch) | |
tree | fe4277340df965a25b73012973016fd26006457f /app | |
parent | f820d18e56f2bd63dd0f91b076ace59345a036a1 (diff) | |
download | gitlab-ce-26774b8d98581b2f211cd5cf04dcec0e352c04a6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/admin/users/components/users_table.vue | 1 | ||||
-rw-r--r-- | app/finders/deployments_finder.rb | 11 | ||||
-rw-r--r-- | app/models/key.rb | 2 | ||||
-rw-r--r-- | app/views/admin/users/_user.html.haml | 72 | ||||
-rw-r--r-- | app/views/admin/users/_users.html.haml | 17 | ||||
-rw-r--r-- | app/workers/ssh_keys/expired_notification_worker.rb | 27 |
6 files changed, 29 insertions, 101 deletions
diff --git a/app/assets/javascripts/admin/users/components/users_table.vue b/app/assets/javascripts/admin/users/components/users_table.vue index ede5c26e487..c848908e024 100644 --- a/app/assets/javascripts/admin/users/components/users_table.vue +++ b/app/assets/javascripts/admin/users/components/users_table.vue @@ -107,6 +107,7 @@ export default { :items="users" :fields="$options.fields" :empty-text="s__('AdminUsers|No users found')" + data-qa-selector="user_row_content" show-empty stacked="md" :tbody-tr-attr="{ 'data-qa-selector': 'user_row_content' }" diff --git a/app/finders/deployments_finder.rb b/app/finders/deployments_finder.rb index acce038dba6..bb9d204ab73 100644 --- a/app/finders/deployments_finder.rb +++ b/app/finders/deployments_finder.rb @@ -136,7 +136,7 @@ class DeploymentsFinder # Implicitly enforce the ordering when filtered by `updated_at` column for performance optimization. # See https://gitlab.com/gitlab-org/gitlab/-/issues/325627#note_552417509. # We remove this in https://gitlab.com/gitlab-org/gitlab/-/issues/328500. - if filter_by_updated_at? && implicitly_enforce_ordering_for_updated_at_filter? + if filter_by_updated_at? sort_params.replace('updated_at' => sort_direction) end @@ -170,15 +170,6 @@ class DeploymentsFinder params[:order_by].to_s == 'finished_at' end - def implicitly_enforce_ordering_for_updated_at_filter? - return false unless params[:project].present? - - ::Feature.enabled?( - :deployments_finder_implicitly_enforce_ordering_for_updated_at_filter, - params[:project], - default_enabled: :yaml) - end - # rubocop: disable CodeReuse/ActiveRecord def preload_associations(scope) scope.includes( diff --git a/app/models/key.rb b/app/models/key.rb index b8b9bd53a63..64385953865 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -7,7 +7,7 @@ class Key < ApplicationRecord include Sortable include Sha256Attribute include Expirable - include EachBatch + include FromUnion sha256_attribute :fingerprint_sha256 diff --git a/app/views/admin/users/_user.html.haml b/app/views/admin/users/_user.html.haml deleted file mode 100644 index 2816a1061b9..00000000000 --- a/app/views/admin/users/_user.html.haml +++ /dev/null @@ -1,72 +0,0 @@ -.gl-responsive-table-row{ role: 'row', data: { qa_selector: 'user_row_content' } } - .table-section.section-40 - .table-mobile-header{ role: 'rowheader' } - = _('Name') - .table-mobile-content - = render 'user_detail', user: user - .table-section.section-10 - .table-mobile-header{ role: 'rowheader' } - = _('Projects') - .table-mobile-content.gl-str-truncated{ data: { testid: "user-project-count-#{user.id}" } } - = user.authorized_projects.length - .table-section.section-15 - .table-mobile-header{ role: 'rowheader' } - = _('Created on') - .table-mobile-content - = l(user.created_at.to_date, format: :admin) - .table-section.section-15 - .table-mobile-header{ role: 'rowheader' } - = _('Last activity') - .table-mobile-content - = user.last_activity_on.nil? ? _('Never') : l(user.last_activity_on, format: :admin) - - unless user.internal? - .table-section.section-20.table-button-footer - .table-action-buttons{ data: { testid: "user-actions-#{user.id}" } } - = link_to _('Edit'), edit_admin_user_path(user), class: 'btn gl-button btn-default' - - unless user == current_user - %button.dropdown-new.btn.gl-button.btn-default{ type: 'button', data: { testid: "dropdown-toggle", toggle: 'dropdown' } } - = sprite_icon('settings') - = sprite_icon('chevron-down') - %ul.dropdown-menu.dropdown-menu-right - %li.dropdown-header - = _('Settings') - %li - - if user.ldap_blocked? - %span.small - = s_('AdminUsers|Cannot unblock LDAP blocked users') - - elsif user.blocked? - - if user.blocked_pending_approval? - = link_to s_('AdminUsers|Approve'), approve_admin_user_path(user), method: :put - = link_to s_('AdminUsers|Reject'), reject_admin_user_path(user), method: :delete - - else - %button.gl-button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_unblock_data(user) } - = s_('AdminUsers|Unblock') - - else - %button.gl-button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) } - = s_('AdminUsers|Block') - - if user.can_be_deactivated? - %li - %button.gl-button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_deactivation_data(user, user_deactivation_effects) } - = s_('AdminUsers|Deactivate') - - elsif user.deactivated? - %li - %button.gl-button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_activation_data(user) } - = s_('AdminUsers|Activate') - - if user.access_locked? - %li - = link_to _('Unlock'), unlock_admin_user_path(user), method: :put, data: { confirm: _('Are you sure?') } - - if can?(current_user, :destroy_user, user) && !user.blocked_pending_approval? - %li.divider - - if user.can_be_removed? - %li - %button.js-delete-user-modal-button.gl-button.btn.btn-danger-tertiary{ data: { 'gl-modal-action': 'delete', - delete_user_url: admin_user_path(user), - block_user_url: block_admin_user_path(user), - username: sanitize_name(user.name) } } - = s_('AdminUsers|Delete user') - %li - %button.js-delete-user-modal-button.gl-button.btn.btn-danger-tertiary{ data: { 'gl-modal-action': 'delete-with-contributions', - delete_user_url: admin_user_path(user, hard_delete: true), - block_user_url: block_admin_user_path(user), - username: sanitize_name(user.name) } } - = s_('AdminUsers|Delete user and contributions') diff --git a/app/views/admin/users/_users.html.haml b/app/views/admin/users/_users.html.haml index e4438f38a47..1a43d91b800 100644 --- a/app/views/admin/users/_users.html.haml +++ b/app/views/admin/users/_users.html.haml @@ -73,20 +73,9 @@ = link_to admin_users_path(sort: value, filter: params[:filter], search_query: params[:search_query]) do = title -- if Feature.enabled?(:vue_admin_users, default_enabled: :yaml) - #js-admin-users-app{ data: admin_users_data_attributes(@users) } - .gl-spinner-container.gl-my-7 - %span.gl-vertical-align-bottom.gl-spinner.gl-spinner-dark.gl-spinner-lg{ aria: { label: _('Loading') } } -- elsif @users.empty? - .nothing-here-block.border-top-0 - = s_('AdminUsers|No users found') -- else - .table-holder - .thead-white.text-nowrap.gl-responsive-table-row.table-row-header{ role: 'row' } - - user_table_headers.each do |header| - .table-section{ class: header[:section_class_name], role: 'rowheader' }= header[:header_text] - - = render partial: 'admin/users/user', collection: @users +#js-admin-users-app{ data: admin_users_data_attributes(@users) } + .gl-spinner-container.gl-my-7 + %span.gl-vertical-align-bottom.gl-spinner.gl-spinner-dark.gl-spinner-lg{ aria: { label: _('Loading') } } = paginate_collection @users diff --git a/app/workers/ssh_keys/expired_notification_worker.rb b/app/workers/ssh_keys/expired_notification_worker.rb index 95c9601a04c..e8baf0c28dd 100644 --- a/app/workers/ssh_keys/expired_notification_worker.rb +++ b/app/workers/ssh_keys/expired_notification_worker.rb @@ -11,12 +11,31 @@ module SshKeys tags :exclude_from_kubernetes idempotent! + BATCH_SIZE = 500 + + # rubocop: disable CodeReuse/ActiveRecord def perform return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) - # rubocop:disable CodeReuse/ActiveRecord - Key.expired_and_not_notified.each_batch(of: 1000) do |relation| # rubocop:disable Cop/InBatches - users = User.where(id: relation.select(:user_id)) + order = Gitlab::Pagination::Keyset::Order.build([ + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'expires_at_utc', + order_expression: Arel.sql("date(expires_at AT TIME ZONE 'UTC')").asc, + nullable: :not_nullable, + distinct: false, + add_to_projections: true + ), + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'id', + order_expression: Key.arel_table[:id].asc + ) + ]) + + scope = Key.expired_and_not_notified.order(order) + + iterator = Gitlab::Pagination::Keyset::Iterator.new(scope: scope, use_union_optimization: true) + iterator.each_batch(of: BATCH_SIZE) do |relation| + users = User.where(id: relation.map(&:user_id)) # Keyset pagination will load the rows users.each do |user| with_context(user: user) do @@ -24,7 +43,7 @@ module SshKeys end end end - # rubocop:enable CodeReuse/ActiveRecord end + # rubocop: enable CodeReuse/ActiveRecord end end |