Merge branch '58297-remove-extraneous-gitaly-calls-from-md-rendering' into 'master'
Remove extraneous DiffNote#supports_suggestion? calls See merge request gitlab-org/gitlab-ce!29027
This commit is contained in:
commit
96e2ff69ac
|
@ -90,7 +90,7 @@ class DiffNote < Note
|
||||||
end
|
end
|
||||||
|
|
||||||
def banzai_render_context(field)
|
def banzai_render_context(field)
|
||||||
super.merge(project: project, suggestions_filter_enabled: supports_suggestion?)
|
super.merge(suggestions_filter_enabled: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -38,7 +38,9 @@ class PreviewMarkdownService < BaseService
|
||||||
head_sha: params[:head_sha],
|
head_sha: params[:head_sha],
|
||||||
start_sha: params[:start_sha])
|
start_sha: params[:start_sha])
|
||||||
|
|
||||||
Gitlab::Diff::SuggestionsParser.parse(text, position: position, project: project)
|
Gitlab::Diff::SuggestionsParser.parse(text, position: position,
|
||||||
|
project: project,
|
||||||
|
supports_suggestion: params[:preview_suggestions])
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview_sugestions?
|
def preview_sugestions?
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Reduce Gitaly calls to improve performance when rendering suggestions
|
||||||
|
merge_request: 29027
|
||||||
|
author:
|
||||||
|
type: performance
|
|
@ -10,10 +10,12 @@ module Gitlab
|
||||||
# Returns an array of Gitlab::Diff::Suggestion which represents each
|
# Returns an array of Gitlab::Diff::Suggestion which represents each
|
||||||
# suggestion in the given text.
|
# suggestion in the given text.
|
||||||
#
|
#
|
||||||
def parse(text, position:, project:)
|
def parse(text, position:, project:, supports_suggestion: true)
|
||||||
return [] unless position.complete?
|
return [] unless position.complete?
|
||||||
|
|
||||||
html = Banzai.render(text, project: nil, no_original_data: true)
|
html = Banzai.render(text, project: nil,
|
||||||
|
no_original_data: true,
|
||||||
|
suggestions_filter_enabled: supports_suggestion)
|
||||||
doc = Nokogiri::HTML(html)
|
doc = Nokogiri::HTML(html)
|
||||||
suggestion_nodes = doc.search('pre.suggestion')
|
suggestion_nodes = doc.search('pre.suggestion')
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,9 @@ describe PreviewMarkdownService do
|
||||||
|
|
||||||
expect(Gitlab::Diff::SuggestionsParser)
|
expect(Gitlab::Diff::SuggestionsParser)
|
||||||
.to receive(:parse)
|
.to receive(:parse)
|
||||||
.with(text, position: position, project: merge_request.project)
|
.with(text, position: position,
|
||||||
|
project: merge_request.project,
|
||||||
|
supports_suggestion: true)
|
||||||
.and_call_original
|
.and_call_original
|
||||||
|
|
||||||
result = service.execute
|
result = service.execute
|
||||||
|
|
|
@ -96,7 +96,7 @@ describe Suggestions::CreateService do
|
||||||
|
|
||||||
it 'creates no suggestion when diff file is not found' do
|
it 'creates no suggestion when diff file is not found' do
|
||||||
expect_next_instance_of(DiffNote) do |diff_note|
|
expect_next_instance_of(DiffNote) do |diff_note|
|
||||||
expect(diff_note).to receive(:latest_diff_file).twice { nil }
|
expect(diff_note).to receive(:latest_diff_file).once { nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
expect { subject.execute }.not_to change(Suggestion, :count)
|
expect { subject.execute }.not_to change(Suggestion, :count)
|
||||||
|
|
Loading…
Reference in New Issue