Sha256: 5b81251c1464e0a95d37c6140baad1417efa16cfaa9815e6502f8f83eb749ec0
Contents?: true
Size: 1.31 KB
Versions: 62
Compression:
Stored size: 1.31 KB
Contents
module Workarea module Search # TODO remove related help in v4 class RelatedHelp include Query include Pagination document Search::Help def query { more_like_this: { min_term_freq: 1, min_doc_freq: 1, fields: %w(name facets.category body), ids: Array(params[:ids]), like_text: params[:like_text] } } end def size Workarea.config.max_admin_related_help end def results @_results ||= if results_with_url_matching.blank? use_more_like_this? ? super : [] elsif use_more_like_this? combine_url_matching_with(super) else [] end end def results_with_url_matching return [] unless params[:for_url].present? Workarea::Help::Article.find_matching_url(params[:for_url]) end def use_more_like_this? params[:like_text].present? || params[:ids].present? end private def combine_url_matching_with(results) max = Workarea.config.max_admin_related_help items = results_with_url_matching.first(max) + results.items items.uniq! PagedArray.from(items.first(max), 1, max, max) end end end end
Version data entries
62 entries across 62 versions & 1 rubygems