app/controllers/collections_controller.rb
# NOTE - object_type and object_id not changed due yet; they are stale names in Solr.
object_type and object_id not changed due yet; they are stale names in Solr.
object_type and object_id not changed due yet ; they are stale names in Solr .
def reindex_items_if_necessary(collection_results)
    collection_item_ids_to_reindex = []
    collection_results.each do |r|
      next if r['instance'].nil?
      if !(r['sort_field'].blank? && r['instance'].sort_field.blank?) && r['sort_field'] != r['instance'].sort_field
        collection_item_ids_to_reindex << r['instance'].id
      elsif r['object_type'] == 'TaxonConcept'
        entry = r['instance'].collected_item.entry
        entry ||= r['instance'].collected_item.reload.entry
        title = entry.name.string
        if title && r['title'] != SolrAPI.text_filter(title)
          collection_item_ids_to_reindex << r['instance'].id
        elsif r['instance'].collected_item.taxon_concept_metric && r['richness_score'] != r['instance'].collected_item.taxon_concept_metric.richness_score
          collection_item_ids_to_reindex << r['instance'].id
        end
      elsif ['Text', 'Image', 'DataObject', 'Video', 'Sound', 'Link', 'Map'].include?(r['object_type'])
        if r['data_rating'] != r['instance'].collected_item.data_rating
          collection_item_ids_to_reindex << r['instance'].id
        end
      end
    end
    EOL::Solr::CollectionItemsCoreRebuilder.reindex_collection_items_by_ids(collection_item_ids_to_reindex.uniq)
  end
def reindex_items_if_necessary ( collection_results ) collection_item_ids_to_reindex = [ ] collection_results . each do | r | next if r [ 'instance' ] . nil? if ! ( r [ 'sort_field' ] . blank? && r [ 'instance' ] . sort_field . blank? ) && r [ 'sort_field' ] != r [ 'instance' ] . sort_field collection_item_ids_to_reindex << r [ 'instance' ] . id elsif r [ 'object_type' ] == 'TaxonConcept' entry = r [ 'instance' ] . collected_item . entry entry ||= r [ 'instance' ] . collected_item . reload . entry title = entry . name . string if title && r [ 'title' ] != SolrAPI . text_filter ( title ) collection_item_ids_to_reindex << r [ 'instance' ] . id elsif r [ 'instance' ] . collected_item . taxon_concept_metric && r [ 'richness_score' ] != r [ 'instance' ] . collected_item . taxon_concept_metric . richness_score collection_item_ids_to_reindex << r [ 'instance' ] . id end elsif [ 'Text' , 'Image' , 'DataObject' , 'Video' , 'Sound' , 'Link' , 'Map' ] . include? ( r [ 'object_type' ] ) if r [ 'data_rating' ] != r [ 'instance' ] . collected_item . data_rating collection_item_ids_to_reindex << r [ 'instance' ] . id end end end EOL :: Solr :: CollectionItemsCoreRebuilder . reindex_collection_items_by_ids ( collection_item_ids_to_reindex . uniq ) end
NOTE - object_type and object_id not changed due yet; they are stale names in Solr.
NOTE - object_type and object_id not changed due yet ; they are stale names in Solr .
# the instance should never be nil, but sometimes it is when the DB and Solr are out of sync # The taxon didn't have a prefferred entry: # this is the same way we get names when indexing collection items, so be consistent
collection_results
<not_specific>