Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
26c3184b62
commit
034e7d969a
|
|
@ -66,3 +66,5 @@ class AwardEmoji < ApplicationRecord
|
||||||
awardable.try(:update_upvotes_count) if upvote?
|
awardable.try(:update_upvotes_count) if upvote?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
AwardEmoji.prepend_mod_with('AwardEmoji')
|
||||||
|
|
|
||||||
|
|
@ -1918,6 +1918,20 @@ class MergeRequest < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lazy_upvotes_count
|
||||||
|
BatchLoader.for(id).batch(default_value: 0) do |ids, loader|
|
||||||
|
counts = AwardEmoji
|
||||||
|
.where(awardable_id: ids)
|
||||||
|
.upvotes
|
||||||
|
.group(:awardable_id)
|
||||||
|
.count
|
||||||
|
|
||||||
|
counts.each do |id, count|
|
||||||
|
loader.call(id, count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_draft_status
|
def set_draft_status
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Preloaders
|
||||||
|
class MergeRequestsPreloader
|
||||||
|
attr_reader :merge_requests
|
||||||
|
|
||||||
|
def initialize(merge_requests)
|
||||||
|
@merge_requests = merge_requests
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
preloader = ActiveRecord::Associations::Preloader.new
|
||||||
|
preloader.preload(merge_requests, { target_project: [:project_feature] })
|
||||||
|
merge_requests.each do |merge_request|
|
||||||
|
merge_request.lazy_upvotes_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
%span.logo-text.d-none.d-lg-block.gl-ml-3
|
%span.logo-text.d-none.d-lg-block.gl-ml-3
|
||||||
= logo_text
|
= logo_text
|
||||||
- if Gitlab.com_and_canary?
|
- if Gitlab.com_and_canary?
|
||||||
= link_to 'https://next.gitlab.com', class: 'canary-badge bg-transparent', target: :_blank, rel: :_noopener do
|
= link_to 'https://next.gitlab.com', class: 'canary-badge bg-transparent', data: { qa_selector: 'canary_badge_link' }, target: :_blank, rel: :_noopener do
|
||||||
%span.gl-badge.gl-bg-green-500.gl-text-white.gl-rounded-pill.gl-font-weight-bold.gl-py-1
|
%span.gl-badge.gl-bg-green-500.gl-text-white.gl-rounded-pill.gl-font-weight-bold.gl-py-1
|
||||||
= _('Next')
|
= _('Next')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,11 @@ Any data or index cleanup needed to support migration retries should be handled
|
||||||
will re-enqueue itself with a delay which is set using the `throttle_delay` option described below. The batching
|
will re-enqueue itself with a delay which is set using the `throttle_delay` option described below. The batching
|
||||||
must be handled within the `migrate` method, this setting controls the re-enqueuing only.
|
must be handled within the `migrate` method, this setting controls the re-enqueuing only.
|
||||||
|
|
||||||
|
- `batch_size` - Sets the number of documents modified during a `batched!` migration run. This size should be set to a value which allows the updates
|
||||||
|
enough time to finish. This can be tuned in combination with the `throttle_delay` option described below. The batching
|
||||||
|
must be handled within a custom `migrate` method or by using the [`Elastic::MigrationBackfillHelper`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/workers/concerns/elastic/migration_backfill_helper.rb)
|
||||||
|
`migrate` method which uses this setting. Default value is 1000 documents.
|
||||||
|
|
||||||
- `throttle_delay` - Sets the wait time in between batch runs. This time should be set high enough to allow each migration batch
|
- `throttle_delay` - Sets the wait time in between batch runs. This time should be set high enough to allow each migration batch
|
||||||
enough time to finish. Additionally, the time should be less than 30 minutes since that is how often the
|
enough time to finish. Additionally, the time should be less than 30 minutes since that is how often the
|
||||||
[`Elastic::MigrationWorker`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/workers/elastic/migration_worker.rb)
|
[`Elastic::MigrationWorker`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/workers/elastic/migration_worker.rb)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
"@gitlab/favicon-overlay": "2.0.0",
|
"@gitlab/favicon-overlay": "2.0.0",
|
||||||
"@gitlab/svgs": "1.212.0",
|
"@gitlab/svgs": "1.212.0",
|
||||||
"@gitlab/tributejs": "1.0.0",
|
"@gitlab/tributejs": "1.0.0",
|
||||||
"@gitlab/ui": "32.10.0",
|
"@gitlab/ui": "32.10.1",
|
||||||
"@gitlab/visual-review-tools": "1.6.1",
|
"@gitlab/visual-review-tools": "1.6.1",
|
||||||
"@rails/actioncable": "6.1.3-2",
|
"@rails/actioncable": "6.1.3-2",
|
||||||
"@rails/ujs": "6.1.3-2",
|
"@rails/ujs": "6.1.3-2",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ module QA
|
||||||
|
|
||||||
view 'app/views/layouts/header/_default.html.haml' do
|
view 'app/views/layouts/header/_default.html.haml' do
|
||||||
element :navbar, required: true
|
element :navbar, required: true
|
||||||
|
element :canary_badge_link
|
||||||
element :user_avatar, required: true
|
element :user_avatar, required: true
|
||||||
element :user_menu, required: true
|
element :user_menu, required: true
|
||||||
element :stop_impersonation_link
|
element :stop_impersonation_link
|
||||||
|
|
@ -168,6 +169,16 @@ module QA
|
||||||
click_element(:stop_impersonation_link)
|
click_element(:stop_impersonation_link)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# To verify whether the user has been directed to a canary web node
|
||||||
|
# @return [Boolean] result of checking existence of :canary_badge_link element
|
||||||
|
# @example:
|
||||||
|
# Menu.perform do |menu|
|
||||||
|
# expect(menu.canary?).to be(true)
|
||||||
|
# end
|
||||||
|
def canary?
|
||||||
|
has_element?(:canary_badge_link)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def within_top_menu(&block)
|
def within_top_menu(&block)
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,26 @@ module QA
|
||||||
yield.tap { clear! } if block_given?
|
yield.tap { clear! } if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# To redirect the browser to a canary or non-canary web node
|
||||||
|
# after loading a subject test page
|
||||||
|
# @param [Boolean] Send to canary true or false
|
||||||
|
# @example:
|
||||||
|
# Runtime::Browser::Session.target_canary(true)
|
||||||
|
def self.target_canary(enable_canary)
|
||||||
|
if QA::Runtime::Env.qa_cookies.to_s.include?("gitlab_canary=true")
|
||||||
|
QA::Runtime::Logger.warn("WARNING: Setting cookie through QA_COOKIES var is incompatible with this method.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
browser = Capybara.current_session.driver.browser
|
||||||
|
|
||||||
|
if enable_canary
|
||||||
|
browser.manage.add_cookie name: "gitlab_canary", value: "true"
|
||||||
|
else
|
||||||
|
browser.manage.delete_cookie("gitlab_canary")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Selenium allows to reset session cookies for current domain only.
|
# Selenium allows to reset session cookies for current domain only.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
RSpec.describe Preloaders::MergeRequestsPreloader do
|
||||||
|
describe '#execute' do
|
||||||
|
let_it_be_with_refind(:merge_requests) { create_list(:merge_request, 3) }
|
||||||
|
let_it_be(:upvotes) { merge_requests.each { |m| create(:award_emoji, :upvote, awardable: m) } }
|
||||||
|
|
||||||
|
it 'does not make n+1 queries' do
|
||||||
|
described_class.new(merge_requests).execute
|
||||||
|
|
||||||
|
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
|
||||||
|
# expectations make sure the queries execute
|
||||||
|
merge_requests.each do |m|
|
||||||
|
expect(m.target_project.project_feature).not_to be_nil
|
||||||
|
expect(m.lazy_upvotes_count).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 1 query for BatchLoader to load all upvotes at once
|
||||||
|
expect(control.count).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'runs extra queries without preloading' do
|
||||||
|
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
|
||||||
|
# expectations make sure the queries execute
|
||||||
|
merge_requests.each do |m|
|
||||||
|
expect(m.target_project.project_feature).not_to be_nil
|
||||||
|
expect(m.lazy_upvotes_count).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 4 queries per merge request =
|
||||||
|
# 1 to load merge request
|
||||||
|
# 1 to load project
|
||||||
|
# 1 to load project_feature
|
||||||
|
# 1 to load upvotes count
|
||||||
|
expect(control.count).to eq(4 * merge_requests.size)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -974,10 +974,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
|
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
|
||||||
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
|
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
|
||||||
|
|
||||||
"@gitlab/ui@32.10.0":
|
"@gitlab/ui@32.10.1":
|
||||||
version "32.10.0"
|
version "32.10.1"
|
||||||
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.10.0.tgz#7c6ff39d2dc0b770237289dedf2eee46a618021b"
|
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.10.1.tgz#36c1e6688c5db85ddea7dcc1fc7e83ea8e3f091f"
|
||||||
integrity sha512-Kr4sDomMmxOr/PgQsfJ45HCHdTjbb9UISYxwtugAGKJKha/zHmpSEtZFu0R1cLhnVUqS0Y+FSgkq2nAw3NuxIA==
|
integrity sha512-Z0qrhbrE1Y4XR9pUPZVLyjVUYOWwZHHwqw81mD3yP3sbSv0ZIxFRq7Ij0JOM1WPW74SM2nHPvSfwe3217xQkyg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/standalone" "^7.0.0"
|
"@babel/standalone" "^7.0.0"
|
||||||
bootstrap-vue "2.18.1"
|
bootstrap-vue "2.18.1"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue