<commit_before># frozen_string_literal: true

module Hyrax
  ##
  # Returns a list of solr documents for collections the item is a part of
  class CollectionMemberService
    include Blacklight::Configurable

    attr_reader :item, :current_ability

    copy_blacklight_config_from(CatalogController)

    ##
    # @param [SolrDocument] item represents a work
    # @param [Hyrax::Ability] ability
    def self.run(item, ability)
      new(item, ability).list_collections
    end

    def initialize(item, ability)
      @item = item
      @current_ability = ability
    end

    def list_collections
      query = collection_search_builder.rows(1000)
      resp = repository.search(query)
      resp.documents
    end

    def collection_search_builder
      @collection_search_builder ||= ParentCollectionSearchBuilder.new([:include_item_ids, :add_paging_to_solr, :add_access_controls_to_solr_params], self)
    end
  end
end<commit_msg>Fix repository access in CollectionMemberService<commit_after># frozen_string_literal: true

module Hyrax
  ##
  # Returns a list of solr documents for collections the item is a part of
  class CollectionMemberService
    include Blacklight::Configurable

    attr_reader :item, :current_ability

    copy_blacklight_config_from(CatalogController)

    ##
    # @param [SolrDocument] item represents a work
    # @param [Hyrax::Ability] ability
    def self.run(item, ability)
      new(item, ability).list_collections
    end

    def initialize(item, ability)
      @item = item
      @current_ability = ability
    end

    def list_collections
      query = collection_search_builder.rows(1000)
      resp = blacklight_config.repository.search(query)
      resp.documents
    end

    def collection_search_builder
      @collection_search_builder ||= ParentCollectionSearchBuilder.new([:include_item_ids, :add_paging_to_solr, :add_access_controls_to_solr_params], self)
    end
  end
end
{'fraction_non_alphanumeric': 0.06887622993267736, 'fraction_numerical': 0.004142931123770067, 'mean_word_length': 3.8542713567839195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5892478', 'n_tokens_mistral': 578, 'n_tokens_neox': 553, 'n_words': 139}