Sha256: 17964c4e1c996cd75b0e1791ce5fbad5b3a998004df7df23ee57b371f9cb9fba

Contents?: true

Size: 896 Bytes

Versions: 46

Compression:

Stored size: 896 Bytes

Contents

module Hyrax
  class TrophyPresenter
    include ModelProxy
    def initialize(solr_document)
      @solr_document = solr_document
    end

    attr_reader :solr_document

    delegate :to_s, :thumbnail_path, to: :solr_document

    # @param user [User] the user to find the TrophyPresentes for.
    # @return [Array<TrophyPresenter>] a list of all the trophy presenters for the user
    def self.find_by_user(user)
      work_ids = user.trophies.pluck(:work_id)
      query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids(work_ids)
      results = Hyrax::WorkRelation.new.search_with_conditions(query)
      results.map { |result| TrophyPresenter.new(document_model.new(result)) }
    rescue RSolr::Error::ConnectionRefused
      []
    end

    def self.document_model
      CatalogController.blacklight_config.document_model
    end
    private_class_method :document_model
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.5 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.4 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.3 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.2 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.9.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.8.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.7.2 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.7.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.7.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.6.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.5.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.5.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-3.0.0.pre.beta2 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.4.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-3.0.0.pre.beta1 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.4.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.3.3 app/presenters/hyrax/trophy_presenter.rb
hyrax-2.3.2 app/presenters/hyrax/trophy_presenter.rb