app/models/spotlight/search.rb in blacklight-spotlight-0.2.0 vs app/models/spotlight/search.rb in blacklight-spotlight-0.3.0
- old
+ new
@@ -7,10 +7,11 @@
belongs_to :exhibit
serialize :query_params, Hash
default_scope { order("weight ASC") }
scope :published, -> { where(on_landing_page: true) }
validates :title, presence: true
+ has_paper_trail
before_create do
self.featured_item_id ||= default_featured_item_id
end
@@ -38,31 +39,36 @@
rows: 1000,
fl: [blacklight_config.solr_document_model.unique_key, blacklight_config.index.title_field, blacklight_config.index.thumbnail_field],
facet: false)
Blacklight::SolrResponse.new(response, {}).docs.map do |result|
- doc = ::SolrDocument.new(result)
+ doc = blacklight_config.solr_document_model.new(result)
[
doc.first(blacklight_config.solr_document_model.unique_key),
doc.first(blacklight_config.index.title_field),
doc.first(blacklight_config.index.thumbnail_field)
]
end
end
+ def as_json(*args)
+ super.merge(featured_image: featured_image, count: count)
+ end
+
def default_featured_item_id
images.first.first if images.present?
end
+ def blacklight_config
+ exhibit.blacklight_config
+ end
+
private
def should_generate_new_friendly_id?
title_changed?
end
- def blacklight_config
- exhibit.blacklight_config
- end
alias_method :current_exhibit, :exhibit
end