app/models/taxon_concept.rb
# Assume this method is expensive.
# TODO - this belongs in the same class as #overview_text_for_user
Assume this method is expensive.
TODO - this belongs in the same class as #overview_text_for_user
Assume this method is expensive . TODO - this belongs in the same class as #overview_text_for_user
def best_article_for_user(the_user)
    if published_exemplar = published_visible_exemplar_article_in_language(the_user.language)
      published_exemplar
    else
      overview_text_objects = text_for_user(User.new, {
        per_page: 30,
        language_ids: the_user.language.all_ids,
        allow_nil_languages: (the_user.language.id == Language.default.id),
        toc_ids: TocItem.possible_overview_ids,
        filter_by_subtype: true })
      overview_text_objects.delete_if { |article| ! article.published? }
      DataObject.preload_associations(overview_text_objects, { data_objects_hierarchy_entries: [ :hierarchy_entry,
        :vetted, :visibility ] })
      return nil if overview_text_objects.empty?
      DataObject.sort_by_rating(overview_text_objects, self).first
    end
  end
def best_article_for_user ( the_user ) if published_exemplar = published_visible_exemplar_article_in_language ( the_user . language ) published_exemplar else overview_text_objects = text_for_user ( User . new , { per_page : 30 , language_ids : the_user . language . all_ids , allow_nil_languages : ( the_user . language . id == Language . default . id ) , toc_ids : TocItem . possible_overview_ids , filter_by_subtype : true } ) overview_text_objects . delete_if { | article | ! article . published? } DataObject . preload_associations ( overview_text_objects , { data_objects_hierarchy_entries : [ :hierarchy_entry , :vetted , :visibility ] } ) return nil if overview_text_objects . empty? DataObject . sort_by_rating ( overview_text_objects , self ) . first end end
Assume this method is expensive.
Assume this method is expensive .
# Sending User.new here since overview text should be the same for all users - curators # and admins should not see hidden text in the overview tab # TODO - really? #text_for_user returns unpublished articles?
the_user
<not_specific>