Class: Sufia::AdminSetService

Inherits:
CurationConcerns::AdminSetService
  • Object
show all
Defined in:
app/services/sufia/admin_set_service.rb

Overview

Returns AdminSets that the current user has permission to use.

Instance Method Summary collapse

Instance Method Details

#search_results_with_work_count(access) ⇒ Array<Array>

This performs a two pass query, first getting the AdminSets and then getting the work counts

Parameters:

  • access (Symbol)

    :read or :edit

Returns:

  • (Array<Array>)

    a list with document, then work count



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/sufia/admin_set_service.rb', line 8

def search_results_with_work_count(access)
  documents = search_results(access)
  ids = documents.map(&:id).join(',')
  join_field = "isPartOf_ssim"
  query = "{!terms f=#{join_field}}#{ids}"
  results = ActiveFedora::SolrService.instance.conn.get(
    ActiveFedora::SolrService.select_path,
    params: { fq: query,
              'facet.field' => join_field }
  )
  counts = results['facet_counts']['facet_fields'][join_field].each_slice(2).to_h
  documents.map do |doc|
    [doc, counts[doc.id]]
  end
end