Sha256: ebe5738137fbc71ac291251c9475b4baa1ca61354a60631af0a14d22dc022c36

Contents?: true

Size: 990 Bytes

Versions: 10

Compression:

Stored size: 990 Bytes

Contents

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

    attr_reader :solr_document

    delegate :to_s, 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 thumbnail_path
      solr_document[CatalogController.blacklight_config.index.thumbnail_field]
    end

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

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.1.0 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.5 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.4 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.3 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.2 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.1 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.0.rc2 app/presenters/hyrax/trophy_presenter.rb
hyrax-1.0.0.rc1 app/presenters/hyrax/trophy_presenter.rb
test_hyrax-0.0.1.alpha app/presenters/hyrax/trophy_presenter.rb