Sha256: 021ee6cc4fa1c1ad3c253fffc592d80f0deda5ba3131e7de5c67ca72b47dd250

Contents?: true

Size: 812 Bytes

Versions: 4

Compression:

Stored size: 812 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)) }
    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

4 entries across 4 versions & 1 rubygems

Version Path
sufia-7.1.0 app/presenters/sufia/trophy_presenter.rb
sufia-7.0.0 app/presenters/sufia/trophy_presenter.rb
sufia-7.0.0.rc2 app/presenters/sufia/trophy_presenter.rb
sufia-7.0.0.rc1 app/presenters/sufia/trophy_presenter.rb