app/models/spotlight/exhibit.rb in blacklight-spotlight-3.0.0.rc3 vs app/models/spotlight/exhibit.rb in blacklight-spotlight-3.0.0.rc4
- old
+ new
@@ -2,11 +2,10 @@
require 'mail'
module Spotlight
##
# Spotlight exhibit
- # rubocop:disable Metrics/ClassLength
class Exhibit < ActiveRecord::Base
class_attribute :themes_selector
include Spotlight::ExhibitAnalytics
include Spotlight::ExhibitDefaults
include Spotlight::ExhibitDocuments
@@ -55,12 +54,12 @@
end
has_many :custom_search_fields, dependent: :delete_all
has_many :feature_pages, -> { for_default_locale }, extend: FriendlyId::FinderMethods
has_many :groups, dependent: :delete_all
+ has_many :job_trackers, as: :on, dependent: :delete_all
has_many :main_navigations, dependent: :delete_all
- has_many :reindexing_log_entries, dependent: :destroy
has_many :resources
has_many :roles, as: :resource, dependent: :delete_all
has_many :searches, dependent: :destroy, extend: FriendlyId::FinderMethods
has_many :solr_document_sidecars, dependent: :delete_all
has_many :users, through: :roles, class_name: Spotlight::Engine.config.user_class
@@ -117,12 +116,12 @@
filters.each_with_object({}) do |filter, hash|
hash.merge! filter.to_hash
end
end
- def reindex_later(user = nil)
- Spotlight::ReindexJob.perform_later(self, new_reindexing_log_entry(user))
+ def reindex_later(current_user = nil)
+ Spotlight::ReindexExhibitJob.perform_later(self, user: current_user)
end
def uploaded_resource_fields
Spotlight::Engine.config.upload_fields
end
@@ -134,11 +133,11 @@
def requested_by
roles.first&.user
end
def reindex_progress
- @reindex_progress ||= ReindexProgress.new(current_reindexing_log_entry)
+ @reindex_progress ||= ReindexProgress.new(self)
end
def available_locales
@available_locales ||= languages.pluck(:locale)
end
@@ -147,21 +146,12 @@
def sanitize_description
self.description = ::Rails::Html::FullSanitizer.new.sanitize(description)
end
- def new_reindexing_log_entry(user = nil)
- Spotlight::ReindexingLogEntry.create(exhibit: self, user: user, items_reindexed_count: 0, job_status: 'unstarted')
- end
-
private
- def current_reindexing_log_entry
- reindexing_log_entries.started_or_completed.first || reindexing_log_entries.build
- end
-
def move_friendly_id_error_to_slug
errors.add :slug, *errors.delete(:friendly_id) if errors[:friendly_id].present?
end
end
- # rubocop:enable Metrics/ClassLength
end