Sha256: d7b59a2a42bcd83b8c4661f7ad07d5b9d4346eb71d8fa03617cc16e2d6dd7960

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

module Workarea
  module Search
    class Admin
      class Review < Search::Admin
        def type
          'review'
        end

        def status
          'active'
        end

        def facets
          super.merge(
            state: state,
            rating: model.rating,
            verification: verification
          )
        end

        def jump_to_text
          nil
        end

        def name
          nil
        end

        def jump_to_position
          6
        end

        def search_text
          [model.product_id, model.user_id]
        end

        def review_text
          [model.title, model.body, product&.name].compact
        end

        def state
          if model.approved?
            I18n.t('workarea.admin.reviews.approved')
          else
            I18n.t('workarea.admin.reviews.pending')
          end
        end

        def verification
          if model.verified?
            I18n.t('workarea.admin.reviews.verified')
          else
            I18n.t('workarea.admin.reviews.unverified')
          end
        end

        def as_document
          super.merge(
            review_text: review_text,
            rating: model.rating
          )
        end

        private

        def product
          @product ||= Catalog::Product.find(model.product_id) rescue nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-reviews-3.1.2 app/models/workarea/search/admin/review.rb
workarea-reviews-3.1.1 app/models/workarea/search/admin/review.rb
workarea-reviews-3.1.0 app/models/workarea/search/admin/review.rb
workarea-reviews-3.0.10 app/models/workarea/search/admin/review.rb
workarea-reviews-3.0.9 app/models/workarea/search/admin/review.rb
workarea-reviews-3.0.8 app/models/workarea/search/admin/review.rb