Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wings] Changing Permissions in AdminstrativeSets opens loads every work in the set... twice #6772

Closed
1 task
orangewolf opened this issue Apr 17, 2024 · 0 comments · Fixed by #6774
Closed
1 task

Comments

@orangewolf
Copy link
Member

Descriptive summary

When editing permissions on an Administrative Set, it loads all the works w/ in the set. This causes the edit to time out.

Steps to reproduce the behavior in User Interface (UI)

  1. Create an Administrative Set
  2. Add 5,000 works to it
  3. Add a group or user to the Administrative Set
  4. Go for ☕ , its gonna either take 10 minutes or time out

Acceptance Criteria/Expected Behavior

  • AdministrativeSet permissions should not load all the works

Related work

This may be related to #6143

The issue is a combination of https://github.com/samvera/hyrax/blob/main/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb#L22 and https://github.com/samvera/hyrax/blob/main/lib/wings/active_fedora_converter.rb#L154

I can't decide if the issue is that the converter shouldn't be loading the members unless :members are passed in or if having the listener call the converter is the wrong thing and it should be loading the AF admin set some other way.

One possible solution we have in CalState Scholarworks right now (which is Hyrax 3.6):

# frozen_string_literal: true

module Wings
  module ActiveFedoraConverterDecorator
    ##
    # apply attributes to the ActiveFedora model
    def apply_attributes_to_model(af_object)
      case af_object
      when Hydra::AccessControl
        add_access_control_attributes(af_object)
      when ActiveFedora::File
        add_file_attributes(af_object)
      else
        converted_attrs = normal_attributes
        af_object.attributes = converted_attrs.except(:members, :files)
        # members can have 3 states, not set, empty or full. Only change AF model if explicitly empty or full
        if converted_attrs.keys.include?(:members)
          members = Array.wrap(converted_attrs.delete(:members))
          members.empty? ? af_object.try(:ordered_members)&.clear : af_object.try(:ordered_members=, members)
          af_object.try(:members)&.replace(members)
        end

        if converted_attrs.keys.include?(:files)
          files = converted_attrs.delete(:files)
          af_object.files.build_or_set(files) if files
        end
      end
    end
  end
end
Wings::ActiveFedoraConverter.prepend(Wings::ActiveFedoraConverterDecorator)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant