Sha256: a77e4c26ae1603ede631b69bd00a79ee4b5c697faf91a252f328b7a6182587df

Contents?: true

Size: 864 Bytes

Versions: 8

Compression:

Stored size: 864 Bytes

Contents

module Sufia
  class TrophyPresenter
    include CurationConcerns::ModelProxy
    def initialize(solr_document)
      @solr_document = solr_document
    end

    attr_reader :solr_document

    delegate :to_s, to: :solr_document

    def self.find_by_user(user)
      work_ids = user.trophies.pluck(:work_id)
      query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids(work_ids)
      results = CurationConcerns::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

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 app/presenters/sufia/trophy_presenter.rb
sufia-7.4.0 app/presenters/sufia/trophy_presenter.rb
sufia-7.3.1 app/presenters/sufia/trophy_presenter.rb
sufia-7.3.0 app/presenters/sufia/trophy_presenter.rb
sufia-7.3.0.rc3 app/presenters/sufia/trophy_presenter.rb
sufia-7.3.0.rc2 app/presenters/sufia/trophy_presenter.rb
sufia-7.3.0.rc1 app/presenters/sufia/trophy_presenter.rb
sufia-7.2.0 app/presenters/sufia/trophy_presenter.rb