Sha256: 89290b3cdda1c79a817d3caa35d374f288d3092379c5679a8d886ed52b6dee82
Contents?: true
Size: 1.63 KB
Versions: 25
Compression:
Stored size: 1.63 KB
Contents
# returns a list of solr documents for collections the item is a part of module Hyrax ## # @deprecated This class is broken for base Hyrax applications. Current users # should call with extreme caution and consider a local implementation as # an alternative. # @see https://github.com/samvera/hyrax/issues/2801 class CollectionSizeService include Blacklight::Configurable include Blacklight::SearchHelper attr_reader :collection copy_blacklight_config_from(CatalogController) def self.run(collection) new(collection).collection_size end def initialize(collection) Deprecation .warn(self, 'CollectionSizeService has been deprecated for removal in ' \ 'Hyrax 3.0. This class is broken for base Hyrax ' \ 'applications. Current users should call with extreme ' \ 'caution and consider a local implementation as an ' \ 'alternative.') @collection = collection end def collection_size query = collection_search_builder.with('id' => collection.id).rows(max_collection_size).merge(fl: [size_field]) resp = repository.search(query) field_name = size_field resp.documents.reduce(0) do |total, doc| total + (doc[field_name].blank? ? 0 : doc[field_name][0].to_f) end end def collection_search_builder @collection_search_builder ||= MemberWithFilesSearchBuilder.new([:include_contained_files, :add_paging_to_solr], self) end def size_field Solrizer.solr_name(:file_size, :symbol) end def max_collection_size 1000 end end end
Version data entries
25 entries across 25 versions & 1 rubygems