Sha256: a1e337789d95b811f7f240442e7ed46ecc2850f3534c309b71cb29c283a2b56b

Contents?: true

Size: 901 Bytes

Versions: 6

Compression:

Stored size: 901 Bytes

Contents

module Workarea
  module Search
    class AdminReviews
      include Query
      include AdminIndexSearch
      include AdminSorting
      include Pagination

      document Search::Admin

      def initialize(params = {})
        super(params.merge(type: 'review'))
      end

      def fields
        super + %w(review_text)
      end

      def facets
        super + [
          TermsFacet.new(self, 'state'),
          TermsFacet.new(self, 'rating'),
          TermsFacet.new(self, 'verification')
        ]
      end

      def sort
        result = super || []

        if params[:sort] == Sort.highest_rating.to_s
          result.prepend(Sort.highest_rating.field => Sort.highest_rating.direction)
        elsif params[:sort] == Sort.lowest_rating.to_s
          result.prepend(Sort.lowest_rating.field => Sort.lowest_rating.direction)
        end

        result
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-reviews-3.1.2 app/queries/workarea/search/admin_reviews.rb
workarea-reviews-3.1.1 app/queries/workarea/search/admin_reviews.rb
workarea-reviews-3.1.0 app/queries/workarea/search/admin_reviews.rb
workarea-reviews-3.0.10 app/queries/workarea/search/admin_reviews.rb
workarea-reviews-3.0.9 app/queries/workarea/search/admin_reviews.rb
workarea-reviews-3.0.8 app/queries/workarea/search/admin_reviews.rb