Class: Spotlight::RenameSidecarFieldJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
JobTracking
Defined in:
app/jobs/spotlight/rename_sidecar_field_job.rb

Overview

After renaming an exhibit-specific field, we also need to update the sidecars that may contain that field

Instance Method Summary collapse

Methods included from JobTracking

#finalize_job_tracker!, #initialize_job_tracker!, #job_tracker, #mark_job_as_failed!

Instance Method Details

#perform(exhibit, old_field, new_field, old_slug = nil, new_slug = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/spotlight/rename_sidecar_field_job.rb', line 11

def perform(exhibit, old_field, new_field, old_slug = nil, new_slug = nil)
  exhibit.solr_document_sidecars.find_each do |s|
    # this data migration should be relatively rare
    migrate_data!(s, old_slug, new_slug)
    migrate_data!(s, old_field, new_slug || new_field) # for backwards compatibility

    # more likely, the indexing rules changed and we have to reindex
    reindex_document!(s) if old_field != new_field && s.data[new_slug || new_field]
  end
end