Method: Sunspot::Search::QueryFacet#rows

Defined in:
lib/sunspot/search/query_facet.rb

#rows(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sunspot/search/query_facet.rb', line 13

def rows(options = {})
  @rows ||=
    begin
      data = @search.facet_response['facet_queries']
      rows = []
      minimum_count =
        case
        when @options[:minimum_count] then @options[:minimum_count]
        when @options[:zeros] then 0
        else 1
        end
      @requested_facets.each do |requested_facet|
        count = data[requested_facet.boolean_phrase] || 0
        if count >= minimum_count
          rows << FacetRow.new(requested_facet.label, count, self)
        end
      end
      sort_rows!(rows)
    end
end