Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-10-14 22:29:35 +0300
committerDouwe Maan <douwe@gitlab.com>2015-10-14 22:29:35 +0300
commit925dc5925b672718ea1f0f08c5bdd492b5ab3e5d (patch)
tree22a58bbe8f2beba9d501667fc0ea274072741788 /lib/gitlab/reference_extractor.rb
parent539de0dd81ea0d831031c06da502254952d87676 (diff)
Cache rendered contents of issues, MRs and notes
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r--lib/gitlab/reference_extractor.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index f34bf7d1d0e..37141efb4c3 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -9,13 +9,12 @@ module Gitlab
@project = project
@current_user = current_user
@load_lazy_references = load_lazy_references
- end
- def analyze(text, cache_key: nil)
- references.clear
+ @texts = []
+ end
- @pipeline = Gitlab::Markdown.cached?(cache_key, pipeline: :full) ? :full : :plain_markdown
- @html = Gitlab::Markdown.render(text, project: project, cache_key: cache_key, pipeline: @pipeline)
+ def analyze(text, options = {})
+ @texts << Gitlab::Markdown.render(text, options.merge(project: project))
end
%i(user label issue merge_request snippet commit commit_range).each do |type|
@@ -46,7 +45,7 @@ module Gitlab
filter = Gitlab::Markdown.const_get(klass)
context = {
- pipeline: [:reference_extraction],
+ pipeline: :reference_extraction,
project: project,
current_user: current_user,
@@ -56,10 +55,11 @@ module Gitlab
reference_filter: filter
}
- context[:pipeline].unshift(filter) unless @pipeline == :full
-
- result = Gitlab::Markdown.render_result(@html, context)
- values = result[:references][filter_type].uniq
+ values = @texts.flat_map do |html|
+ text_context = context.dup
+ result = Gitlab::Markdown.render_result(html, text_context)
+ result[:references][filter_type]
+ end.uniq
if @load_lazy_references
values = Gitlab::Markdown::ReferenceFilter::LazyReference.load(values).uniq