Sha256: ee88d5139b05d56a262ffb4e989ca64860025318e7dc8b4fc64f9b151f60e2ec

Contents?: true

Size: 589 Bytes

Versions: 17

Compression:

Stored size: 589 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::Facet
  attr_reader :name

  def initialize(name, properties)
    @name, @properties = name, properties
  end

  def filter_type
    use_field? ? :conditions : :with
  end

  def results_from(raw)
    raw.inject({}) { |hash, row|
      hash[row[group_column]] = row["sphinx_internal_count"]
      hash
    }
  end

  private

  def group_column
    @properties.any?(&:multi?) ? "sphinx_internal_group" : name
  end

  def use_field?
    @properties.any? { |property|
      property.type.nil? || property.type == :string
    }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/facet.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/facet.rb