Sha256: 97c31da038c45ec6a34180d356e8112765776eb51b9b14b91f5e774d7065c193
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
class Spotlight::Search < ActiveRecord::Base self.table_name = 'spotlight_searches' belongs_to :exhibit serialize :query_params, Hash default_scope { order("weight ASC") } scope :published, -> { where(on_landing_page: true) } before_create do self.featured_image ||= default_featured_image end include Blacklight::SolrHelper def count query_solr(query_params, rows: 0, facet: false)['response']['numFound'] end def images query_solr(query_params, rows: 1000, fl: [blacklight_config.index.title_field, blacklight_config.index.thumbnail_field], facet: false)['response']['docs'].map {|result| [result[blacklight_config.index.title_field].first, result[blacklight_config.index.thumbnail_field].first]} end def default_featured_image images.first.last end private def blacklight_config CatalogController.blacklight_config end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blacklight-spotlight-0.0.2 | app/models/spotlight/search.rb |
blacklight-spotlight-0.0.1 | app/models/spotlight/search.rb |