Class: Spotlight::Exhibit

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/spotlight/exhibit.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject

Find or create the default exhibit



70
71
72
73
74
# File 'app/models/spotlight/exhibit.rb', line 70

def self.default
  self.find_or_create_by!(default: true) do |e|
    e.title = 'Default exhibit'.freeze
  end
end

Instance Method Details

#analytics(start_date = 1.month, path = nil) ⇒ Object



97
98
99
100
101
102
103
# File 'app/models/spotlight/exhibit.rb', line 97

def analytics start_date = 1.month, path = nil
  return OpenStruct.new unless analytics_provider and analytics_provider.enabled?
  @analytics ||= {}
  @analytics[start_date] ||= begin
    analytics_provider.exhibit_data(path || self, start_date: start_date.ago)
  end
end

#appearanceObject



93
94
95
# File 'app/models/spotlight/exhibit.rb', line 93

def appearance
  Spotlight::Appearance.new(blacklight_configuration)
end

#has_browse_categories?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'app/models/spotlight/exhibit.rb', line 76

def has_browse_categories?
  searches.published.any?
end

#import(hash) ⇒ Object



84
85
86
87
# File 'app/models/spotlight/exhibit.rb', line 84

def import hash
  Spotlight::ExhibitExportSerializer.prepare(self).from_hash(hash)
  self
end

#main_about_pageObject



65
66
67
# File 'app/models/spotlight/exhibit.rb', line 65

def main_about_page
  @main_about_page ||= about_pages.published.first
end

#page_analytics(start_date = 1.month, path = nil) ⇒ Object



105
106
107
108
109
110
111
112
# File 'app/models/spotlight/exhibit.rb', line 105

def page_analytics start_date = 1.month, path = nil
  return [] unless analytics_provider and analytics_provider.enabled?
  
  @page_analytics ||= {}
  @page_analytics[start_date] ||= begin
    analytics_provider.page_data(path || self, start_date: start_date.ago)
  end
end

#reindex_laterObject



114
115
116
# File 'app/models/spotlight/exhibit.rb', line 114

def reindex_later
  Spotlight::ReindexJob.perform_later(self)
end

#solr_dataObject



89
90
91
# File 'app/models/spotlight/exhibit.rb', line 89

def solr_data
  { :"#{Spotlight::Engine.config.solr_fields.prefix}spotlight_exhibit_slug_#{slug}#{Spotlight::Engine.config.solr_fields.boolean_suffix}" => true }
end

#to_sObject



80
81
82
# File 'app/models/spotlight/exhibit.rb', line 80

def to_s
  title
end

#uploaded_resource_fieldsObject



118
119
120
# File 'app/models/spotlight/exhibit.rb', line 118

def uploaded_resource_fields
  Spotlight::Engine.config.upload_fields
end