Sha256: f95606aff018f70ea6e6456e5926c3177f86e8e5cdde8bb6f8b4bf18e7e43239

Contents?: true

Size: 1.77 KB

Versions: 18

Compression:

Stored size: 1.77 KB

Contents

module Hyrax
  module Actors
    # When adding member FileSets to a Work, Hyrax saves
    #   and reloads the work for each new member FileSet.
    #   This can significantly slow down ingest for Works
    #   with many member FileSets. The saving and reloading
    #   happens in FileSetActor#attach_to_work.
    #
    # This is a 'swappable' alternative approach. It will
    #   be of most value to Hyrax applications dealing with
    #   works with many filesets. Anecdotally, a work with
    #   600 filesets can be processed in ~15 mins versus
    #   > 3 hours with the standard approach.
    #
    # The tradeoff is that the ordered members are now added in a
    #   single step after the creation of all the FileSets, thus
    #   introducing a slight risk of orphan filesets if the upload
    #   fails before the addition of the ordered members. This
    #   has not been observed in practice.
    #
    # Swapping out the actors can be achieved thus:
    #
    # In `config/initializers/hyrax.rb`:
    # ```
    # Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
    #   Hyrax::Actors::CreateWithFilesOrderedMembersActor)
    # ```
    # Alternatively, in `config/application.rb`:
    # ```
    # config.to_prepare
    #   Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
    #     Hyrax::Actors::CreateWithFilesOrderedMembersActor)
    # end
    # ```
    # Creates a work and attaches files to the work
    class CreateWithFilesOrderedMembersActor < CreateWithFilesActor
      # @return [TrueClass]
      def attach_files(files, env)
        return true if files.blank?
        AttachFilesToWorkWithOrderedMembersJob.perform_later(env.curation_concern, files, env.attributes.to_h.symbolize_keys)
        true
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.5 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.4 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.3 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.2 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.1 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.9.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.8.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.7.2 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.7.1 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.7.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.6.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.5.1 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.5.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-3.0.0.pre.beta2 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.4.1 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-3.0.0.pre.beta1 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb
hyrax-2.4.0 app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb