2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module Gitlab
|
|
|
|
module Search
|
|
|
|
class ParsedQuery
|
|
|
|
attr_reader :term, :filters
|
|
|
|
|
|
|
|
def initialize(term, filters)
|
|
|
|
@term = term
|
|
|
|
@filters = filters
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_results(results)
|
|
|
|
filters = @filters.reject { |filter| filter[:matcher].nil? }
|
|
|
|
return unless filters
|
|
|
|
|
|
|
|
results.select do |result|
|
|
|
|
filters.all? do |filter|
|
|
|
|
filter[:matcher].call(filter, result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
Gitlab::Search::ParsedQuery.prepend_if_ee('EE::Gitlab::Search::ParsedQuery')
|