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 10:17:05 +0300
committerDouwe Maan <douwe@gitlab.com>2015-10-14 10:17:05 +0300
commitd6fb96b9276d1a9edfae261d2eba2f79f8a9f340 (patch)
tree848a0fe95e83d125eaa1ab49b497a2626fb6284c /lib/gitlab/reference_extractor.rb
parentcd2583a3beed95a91eddf4e6f868507dcf499481 (diff)
Have Issue#participants load all users mentioned in notes using a single query
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r--lib/gitlab/reference_extractor.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index d6b739d7b9a..895a23ddcc8 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -3,17 +3,17 @@ require 'gitlab/markdown'
module Gitlab
# Extract possible GFM references from an arbitrary String for further processing.
class ReferenceExtractor
- attr_accessor :project, :current_user
+ attr_accessor :project, :current_user, :load_lazy_references
- def initialize(project, current_user = nil)
+ def initialize(project, current_user = nil, load_lazy_references: true)
@project = project
@current_user = current_user
+ @load_lazy_references = load_lazy_references
end
- def analyze(texts)
+ def analyze(text)
references.clear
- texts = Array(texts)
- @texts = texts.map { |text| Gitlab::Markdown.render_without_gfm(text) }
+ @text = Gitlab::Markdown.render_without_gfm(text)
end
%i(user label issue merge_request snippet commit commit_range).each do |type|
@@ -29,7 +29,7 @@ module Gitlab
type = type.to_sym
return references[type] if references.has_key?(type)
- references[type] = pipeline_result(type).uniq
+ references[type] = pipeline_result(type)
end
end
@@ -53,14 +53,15 @@ module Gitlab
}
pipeline = HTML::Pipeline.new([filter, Gitlab::Markdown::ReferenceGathererFilter], context)
+ result = pipeline.call(@text)
- values = @texts.flat_map do |text|
- result = pipeline.call(text)
+ values = result[:references][filter_type].uniq
- result[:references][filter_type]
+ if @load_lazy_references
+ values = Gitlab::Markdown::ReferenceFilter::LazyReference.load(values).uniq
end
- Gitlab::Markdown::ReferenceFilter::LazyReference.load(values)
+ values
end
end
end