app/models/tramea.rb
# NOTE: This is the motherload: a taxon page!
This is the motherload: a taxon page!
This is the motherload : a taxon page!
def page_from_taxon_concept(taxon, options = {})
      options["images_page"] ||= 1
      options["images_per_page"] ||= 4
      options["articles_page"] ||= 1
      options["articles_per_page"] ||= 1
      options["traits_page"] ||= 1
      options["traits_per_page"] ||= 10
      data = PageTraits.new(taxon.id).traits
      hash = {
        "id" => taxon.id,
        "curator" => {"id" => 1, "name" => "EOL Curation Team"},
        "node_ids" => taxon.hierarchy_entry_ids,
        "node" => node_from_hierarchy_entry(taxon.entry),
        "images" => {
          "page" => options["images_page"],
          "per_page" => options["images_per_page"],
          "total" => "TODO",
          : manage the exemplar image; it should be first.
          "images" => taxon.
            images_from_solr(
              options["images_per_page"],
              ignore_translations: true
            ).map { |image| image_from_data_object(image, taxon) }
        },
        "articles" => {
          "page" => options["articles_page"],
          "per_page" => options["articles_per_page"],
          "total" => "TODO",
          : handle paginatation rather than just the summary:
          "articles" => [
              article_from_data_object(taxon.overview_text_for_user(User.first),
                taxon)
            ]
        },
         - Add trait ranges.
        : handle pagination of traits rather than just the overview-y ones:
        "traits" => {
          "page" => options["traits_page"],
          "per_page" => options["traits_per_page"],
          "total" => data.distinct_predicates.count,
          : handle paginatation rather than just the summary:
          "traits" => data.get_data_for_overview.values.map do |h|
            h[:data_point_uris]
          end.flatten.map do |datum|
            trait_from_data_point_uri(datum)
          end
        }
      }
      if options["common_names"]
        hash["common_names"] = taxon.common_names.map do |name|
          common_name_from_taxon_concept_name(name)
        end
      else 
        hash["common_name"] = common_name_from_taxon_concept_name(
          taxon.common_taxon_concept_name
        )
      end
      hash["synonyms"] = synonyms_from_taxon_concept(taxon) if
        options["synonyms"]
      hash
    end
def page_from_taxon_concept ( taxon , options = { } ) options [ "images_page" ] ||= 1 options [ "images_per_page" ] ||= 4 options [ "articles_page" ] ||= 1 options [ "articles_per_page" ] ||= 1 options [ "traits_page" ] ||= 1 options [ "traits_per_page" ] ||= 10 data = PageTraits . new ( taxon . id ) . traits hash = { "id" => taxon . id , "curator" => { "id" => 1 , "name" => "EOL Curation Team" } , "node_ids" => taxon . hierarchy_entry_ids , "node" => node_from_hierarchy_entry ( taxon . entry ) , "images" => { "page" => options [ "images_page" ] , "per_page" => options [ "images_per_page" ] , "total" => "TODO" , "images" => taxon . images_from_solr ( options [ "images_per_page" ] , ignore_translations : true ) . map { | image | image_from_data_object ( image , taxon ) } } , "articles" => { "page" => options [ "articles_page" ] , "per_page" => options [ "articles_per_page" ] , "total" => "TODO" , "articles" => [ article_from_data_object ( taxon . overview_text_for_user ( User . first ) , taxon ) ] } , "traits" => { "page" => options [ "traits_page" ] , "per_page" => options [ "traits_per_page" ] , "total" => data . distinct_predicates . count , "traits" => data . get_data_for_overview . values . map do | h | h [ :data_point_uris ] end . flatten . map do | datum | trait_from_data_point_uri ( datum ) end } } if options [ "common_names" ] hash [ "common_names" ] = taxon . common_names . map do | name | common_name_from_taxon_concept_name ( name ) end else hash [ "common_name" ] = common_name_from_taxon_concept_name ( taxon . common_taxon_concept_name ) end hash [ "synonyms" ] = synonyms_from_taxon_concept ( taxon ) if options [ "synonyms" ] hash end
NOTE: This is the motherload: a taxon page!
NOTE : This is the motherload : a taxon page!
# TODO: this will no longer work, because I stopped calling TaxonData. Fix. # TODO: "curator" is a PLACEHOLDER, meant to show that, in the future, # when you're a curator and you want to see hidden content, JUST LOAD # TWO OF THESE, and show the differences. The other will have a # 'curator' of 'uncurated' (id 0). Simple. The question that remains, of # course, is how to store the relationship between a curated page and # its media. # TODO: the map. # TODO # TODO: manage the exemplar image; it should be first. # TODO # TODO: handle paginatation rather than just the summary: # The user argument here doesn't matter, really (q.v.). # TODO - Add trait ranges. # TODO: handle pagination of traits rather than just the overview-y ones: # TODO # TODO: handle paginatation rather than just the summary: # NOTE: Yeah, weird structure from this method. # Let's give them one common name, at least:
taxon
<not_specific>
options
<not_specific>