samvera / active_fedora

A Rails interface to the Fedora repository, akin to ActiveModel
Other
54 stars 63 forks source link

Use lazy Solr results in CollectionAssociation#find_target #1358

Open botimer opened 6 years ago

botimer commented 6 years ago

Per https://github.com/samvera/active_fedora/blob/fe9ca1cd07031c1423c2e37f3d5bd0e96e4fb6d0/lib/active_fedora/associations/collection_association.rb#L302,

        def find_target
          # TODO: don't reify, just store the solr results and lazily reify.
          # For now, we set a hard limit of 1000 results.
          records = ActiveFedora::QueryResultBuilder.reify_solr_results(load_from_solr(rows: SolrService::MAX_ROWS))
          records.each { |record| set_inverse_instance(record) }
          records
        rescue ObjectNotFoundError, Ldp::Gone => e
          ActiveFedora::Base.logger.error "Solr and Fedora may be out of sync:\n" + e.message
          reset
          []
        end