debian-mirror-gitlab/lib/gitlab/search/parsed_query.rb
2020-05-25 16:23:42 +05:30

27 lines
599 B
Ruby

# frozen_string_literal: true
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
Gitlab::Search::ParsedQuery.prepend_if_ee('EE::Gitlab::Search::ParsedQuery')