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

parsed_query.rb « search « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 23595f23f01a3348991ec0f12112704471c804fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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