diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-07 15:10:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-07 15:10:00 +0300 |
commit | de8e5077c3671b0b29642faf1b5e562bc4f99453 (patch) | |
tree | 315d59367b7ff609ed4293f369c14be9e7e91cba /app | |
parent | f4c6fbb86fbec3e5917e317b3490232d98531881 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/batch_comments/components/preview_item.vue | 10 | ||||
-rw-r--r-- | app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js | 11 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/layout.scss | 12 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/system_messages.scss | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/print.scss | 2 | ||||
-rw-r--r-- | app/controllers/admin/dashboard_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/groups/registry/repositories_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/health_controller.rb | 1 | ||||
-rw-r--r-- | app/mailers/emails/service_desk.rb | 8 | ||||
-rw-r--r-- | app/models/key.rb | 5 | ||||
-rw-r--r-- | app/models/user.rb | 11 | ||||
-rw-r--r-- | app/policies/project_policy.rb | 2 | ||||
-rw-r--r-- | app/services/users/refresh_authorized_projects_service.rb | 9 | ||||
-rw-r--r-- | app/views/layouts/_page.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/fullscreen.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/terms.html.haml | 2 | ||||
-rw-r--r-- | app/workers/ssh_keys/expired_notification_worker.rb | 14 |
17 files changed, 49 insertions, 50 deletions
diff --git a/app/assets/javascripts/batch_comments/components/preview_item.vue b/app/assets/javascripts/batch_comments/components/preview_item.vue index 753608cf6f7..0eb4e6e7709 100644 --- a/app/assets/javascripts/batch_comments/components/preview_item.vue +++ b/app/assets/javascripts/batch_comments/components/preview_item.vue @@ -46,9 +46,13 @@ export default { } if (this.discussion) { - return sprintf(__("%{authorsName}'s thread"), { - authorsName: this.discussion.notes.find((note) => !note.system).author.name, - }); + return sprintf( + __("%{authorsName}'s thread"), + { + authorsName: this.discussion.notes.find((note) => !note.system).author.name, + }, + false, + ); } return __('Your new comment'); diff --git a/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js b/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js index 860e5372bc2..d26f32a7e7a 100644 --- a/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js +++ b/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js @@ -1,4 +1,4 @@ -import { mapValues, omit } from 'lodash'; +import { mapValues } from 'lodash'; import { InputRule } from 'prosemirror-inputrules'; import { ENTER_KEY, BACKSPACE_KEY } from '~/lib/utils/keys'; import Tracking from '~/tracking'; @@ -36,15 +36,16 @@ const trackInputRulesAndShortcuts = (tiptapExtension) => { addKeyboardShortcuts() { const shortcuts = this.parent?.() || {}; const { name } = this; - /** * We don’t want to track keyboard shortcuts * that are not deliberately executed to create * new types of content */ - const withoutEnterShortcut = omit(shortcuts, [ENTER_KEY, BACKSPACE_KEY]); - const decorated = mapValues(withoutEnterShortcut, (commandFn, shortcut) => - trackKeyboardShortcut(name, commandFn, shortcut), + const dotNotTrackKeys = [ENTER_KEY, BACKSPACE_KEY]; + const decorated = mapValues(shortcuts, (commandFn, shortcut) => + dotNotTrackKeys.includes(shortcut) + ? commandFn + : trackKeyboardShortcut(name, commandFn, shortcut), ); return decorated; diff --git a/app/assets/stylesheets/framework/layout.scss b/app/assets/stylesheets/framework/layout.scss index 4f9896dd58a..e00bb83362a 100644 --- a/app/assets/stylesheets/framework/layout.scss +++ b/app/assets/stylesheets/framework/layout.scss @@ -38,8 +38,11 @@ body { } } -.content-wrapper { +.content-wrapper-margin { margin-top: $header-height; +} + +.content-wrapper { padding-bottom: 100px; } @@ -166,15 +169,8 @@ body { } .content-wrapper { - margin-top: 0; padding-bottom: 0; flex: 1; min-height: 0; } - - &.flash-shown { - .content-wrapper { - margin-top: 0; - } - } } diff --git a/app/assets/stylesheets/framework/system_messages.scss b/app/assets/stylesheets/framework/system_messages.scss index 10796f319bf..437915d5034 100644 --- a/app/assets/stylesheets/framework/system_messages.scss +++ b/app/assets/stylesheets/framework/system_messages.scss @@ -52,7 +52,7 @@ top: $system-header-height + $header-height; } - .content-wrapper { + .content-wrapper-margin { margin-top: $system-header-height + $header-height; } @@ -90,7 +90,7 @@ bottom: $system-footer-height; } - .content-wrapper { + .content-wrapper-margin { margin-bottom: 16px; } diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 1d0333d1e2f..ab86a2f69dd 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -65,6 +65,6 @@ a[href]::after { margin-top: 0; } -.content-wrapper { +.content-wrapper-margin { margin-top: 0; } diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index ba24e3e619b..46e5a508a1b 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -15,7 +15,7 @@ class Admin::DashboardController < Admin::ApplicationController @groups = Group.order_id_desc.with_route.limit(10) @notices = Gitlab::ConfigChecker::PumaRuggedChecker.check @notices += Gitlab::ConfigChecker::ExternalDatabaseChecker.check - @redis_versions = [Gitlab::Redis::Queues, Gitlab::Redis::SharedState, Gitlab::Redis::Cache, Gitlab::Redis::TraceChunks].map(&:version).uniq + @redis_versions = [Gitlab::Redis::Queues, Gitlab::Redis::SharedState, Gitlab::Redis::Cache].map(&:version).uniq end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/groups/registry/repositories_controller.rb b/app/controllers/groups/registry/repositories_controller.rb index d914e0bffc6..3aaaf6ade6b 100644 --- a/app/controllers/groups/registry/repositories_controller.rb +++ b/app/controllers/groups/registry/repositories_controller.rb @@ -17,7 +17,7 @@ module Groups .execute .with_api_entity_associations - track_package_event(:list_repositories, :container) + track_package_event(:list_repositories, :container, user: current_user, namespace: group) serializer = ContainerRepositoriesSerializer .new(current_user: current_user) diff --git a/app/controllers/health_controller.rb b/app/controllers/health_controller.rb index 99b0b775217..c6a02250896 100644 --- a/app/controllers/health_controller.rb +++ b/app/controllers/health_controller.rb @@ -15,7 +15,6 @@ class HealthController < ActionController::Base Gitlab::HealthChecks::Redis::CacheCheck, Gitlab::HealthChecks::Redis::QueuesCheck, Gitlab::HealthChecks::Redis::SharedStateCheck, - Gitlab::HealthChecks::Redis::TraceChunksCheck, Gitlab::HealthChecks::GitalyCheck ].freeze diff --git a/app/mailers/emails/service_desk.rb b/app/mailers/emails/service_desk.rb index 66eb2c646a9..e8034ef9b57 100644 --- a/app/mailers/emails/service_desk.rb +++ b/app/mailers/emails/service_desk.rb @@ -20,7 +20,9 @@ module Emails options = service_desk_options(email_sender, 'thank_you', @issue.external_author) .merge(subject: "Re: #{subject_base}") - mail_new_thread(@issue, options) + mail_new_thread(@issue, options).tap do + Gitlab::Metrics::BackgroundTransaction.current&.add_event(:service_desk_thank_you_email) + end end def service_desk_new_note_email(issue_id, note_id, recipient) @@ -31,7 +33,9 @@ module Emails options = service_desk_options(email_sender, 'new_note', recipient) .merge(subject: subject_base) - mail_answer_thread(@issue, options) + mail_answer_thread(@issue, options).tap do + Gitlab::Metrics::BackgroundTransaction.current&.add_event(:service_desk_new_note_email) + end end private diff --git a/app/models/key.rb b/app/models/key.rb index 15b3c460b52..b8b9bd53a63 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -7,6 +7,7 @@ class Key < ApplicationRecord include Sortable include Sha256Attribute include Expirable + include EachBatch sha256_attribute :fingerprint_sha256 @@ -43,7 +44,9 @@ class Key < ApplicationRecord scope :preload_users, -> { preload(:user) } scope :for_user, -> (user) { where(user: user) } scope :order_last_used_at_desc, -> { reorder(::Gitlab::Database.nulls_last_order('last_used_at', 'DESC')) } - scope :expired_today_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') = CURRENT_DATE AND expiry_notification_delivered_at IS NULL"]) } + + # Date is set specifically in this scope to improve query time. + scope :expired_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') BETWEEN '2000-01-01' AND CURRENT_DATE AND expiry_notification_delivered_at IS NULL"]) } scope :expiring_soon_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') > CURRENT_DATE AND date(expires_at AT TIME ZONE 'UTC') < ? AND before_expiry_notification_delivered_at IS NULL", DAYS_TO_EXPIRE.days.from_now.to_date]) } def self.regular_keys diff --git a/app/models/user.rb b/app/models/user.rb index a7964cf0001..5eab59f657f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -108,7 +108,7 @@ class User < ApplicationRecord # Profile has_many :keys, -> { regular_keys }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent - has_many :expired_today_and_unnotified_keys, -> { expired_today_and_not_notified }, class_name: 'Key' + has_many :expired_and_unnotified_keys, -> { expired_and_not_notified }, class_name: 'Key' has_many :expiring_soon_and_unnotified_keys, -> { expiring_soon_and_not_notified }, class_name: 'Key' has_many :deploy_keys, -> { where(type: 'DeployKey') }, dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent has_many :group_deploy_keys @@ -411,14 +411,7 @@ class User < ApplicationRecord .without_impersonation .expired_today_and_not_notified) end - scope :with_ssh_key_expired_today, -> do - includes(:expired_today_and_unnotified_keys) - .where('EXISTS (?)', - ::Key - .select(1) - .where('keys.user_id = users.id') - .expired_today_and_not_notified) - end + scope :with_ssh_key_expiring_soon, -> do includes(:expiring_soon_and_unnotified_keys) .where('EXISTS (?)', diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 5e9633d1c8a..df06f0a95fe 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -238,6 +238,7 @@ class ProjectPolicy < BasePolicy enable :admin_issue_board enable :download_code enable :read_statistics + enable :daily_statistics enable :download_wiki_code enable :create_snippet enable :update_issue @@ -346,7 +347,6 @@ class ProjectPolicy < BasePolicy enable :update_deployment enable :create_release enable :update_release - enable :daily_statistics enable :create_metrics_dashboard_annotation enable :delete_metrics_dashboard_annotation enable :update_metrics_dashboard_annotation diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index d28ff45bfdf..1850fa9747d 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -24,11 +24,6 @@ module Users @source = source @incorrect_auth_found_callback = incorrect_auth_found_callback @missing_auth_found_callback = missing_auth_found_callback - - # We need an up to date User object that has access to all relations that - # may have been created earlier. The only way to ensure this is to reload - # the User object. - user.reset end def execute @@ -43,6 +38,10 @@ module Users end begin + # We need an up to date User object that has access to all relations that + # may have been created earlier. The only way to ensure this is to reload + # the User object. + user.reset execute_without_lease ensure Gitlab::ExclusiveLease.cancel(lease_key, uuid) diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index c91d27e3ed1..61f03c0540d 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -1,7 +1,7 @@ .layout-page{ class: page_with_sidebar_class } - if defined?(nav) && nav = render "layouts/nav/sidebar/#{nav}" - .content-wrapper{ class: "#{@content_wrapper_class}" } + .content-wrapper.content-wrapper-margin{ class: "#{@content_wrapper_class}" } .mobile-overlay = yield :group_invite_members_banner .alert-wrapper.gl-force-block-formatting-context diff --git a/app/views/layouts/fullscreen.html.haml b/app/views/layouts/fullscreen.html.haml index 63bb9f8fff5..f46c58f96ee 100644 --- a/app/views/layouts/fullscreen.html.haml +++ b/app/views/layouts/fullscreen.html.haml @@ -11,6 +11,6 @@ = render "layouts/broadcast" = yield :flash_message = render "layouts/flash" - .content-wrapper{ id: "content-body", class: "d-flex flex-column align-items-stretch mt-0" } + .content-wrapper{ id: "content-body", class: "d-flex flex-column align-items-stretch" } = yield = footer_message diff --git a/app/views/layouts/terms.html.haml b/app/views/layouts/terms.html.haml index e39cb5ee0a2..4d5c354388f 100644 --- a/app/views/layouts/terms.html.haml +++ b/app/views/layouts/terms.html.haml @@ -5,7 +5,7 @@ %body{ data: { page: body_data_page } } .layout-page.terms{ class: page_class } - .content-wrapper.gl-mt-0 + .content-wrapper .mobile-overlay .alert-wrapper = render "layouts/broadcast" diff --git a/app/workers/ssh_keys/expired_notification_worker.rb b/app/workers/ssh_keys/expired_notification_worker.rb index 9d5143fe655..95c9601a04c 100644 --- a/app/workers/ssh_keys/expired_notification_worker.rb +++ b/app/workers/ssh_keys/expired_notification_worker.rb @@ -15,16 +15,16 @@ module SshKeys return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) # rubocop:disable CodeReuse/ActiveRecord - User.with_ssh_key_expired_today.find_each(batch_size: 10_000) do |user| - with_context(user: user) do - Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expired ssh key(s)" + Key.expired_and_not_notified.each_batch(of: 1000) do |relation| # rubocop:disable Cop/InBatches + users = User.where(id: relation.select(:user_id)) - keys = user.expired_today_and_unnotified_keys - - Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: false }).execute + users.each do |user| + with_context(user: user) do + Keys::ExpiryNotificationService.new(user, { keys: user.expired_and_unnotified_keys, expiring_soon: false }).execute + end end - # rubocop:enable CodeReuse/ActiveRecord end + # rubocop:enable CodeReuse/ActiveRecord end end end |