Sha256: 450adc0fb660be28a6a8be125319757136fbfe9be637470452073480fbe545cf
Contents?: true
Size: 1.09 KB
Versions: 12
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Arclight # Controller for our /repositories index page class RepositoriesController < ApplicationController def index @repositories = Arclight::Repository.all load_collection_counts end def show @repository = Arclight::Repository.find_by!(slug: params[:id]) search_service = Blacklight.repository_class.new(blacklight_config) @response = search_service.search( q: "level_sim:Collection repository_sim:\"#{@repository.name}\"", rows: 100 ) @collections = @response.documents end private def load_collection_counts counts = fetch_collection_counts @repositories.each do |repository| repository.collection_count = counts[repository.name] || 0 end end def fetch_collection_counts search_service = Blacklight.repository_class.new(blacklight_config) results = search_service.search( q: 'level_sim:Collection', 'facet.field': 'repository_sim', rows: 0 ) Hash[*results.facet_fields['repository_sim']] end end end
Version data entries
12 entries across 12 versions & 1 rubygems