app/models/trait_set.rb
# NOTE: Sorry this is complex, but: there are a lot of considerations for
# sort!
Sorry this is complex, but: there are a lot of considerations for
sort!
Sorry this is complex but : there are a lot of considerations for sort!
def traits_by_category(category)
    populate
    subset = if category == :other
      traits.select { |trait| trait.categories.empty? }
    else
      traits.select { |trait| trait.categories.include?(category) }
    end
    subset.sort_by do |trait|
      predicate = trait.predicate_name.try(:downcase)
      value_label = trait.value_name.try(:downcase)
      sex_sort = trait.sex_name || 255.chr
      stage_sort = trait.life_stage_name || ''
      stats_sort = trait.statistical_method? ?
        trait.statistical_methods.first.position : 65000
      [ trait.predicate_uri.position, predicate, sex_sort,
        stats_sort, stage_sort, value_label ]
    end
  end
def traits_by_category ( category ) populate subset = if category == :other traits . select { | trait | trait . categories . empty? } else traits . select { | trait | trait . categories . include? ( category ) } end subset . sort_by do | trait | predicate = trait . predicate_name . try ( :downcase ) value_label = trait . value_name . try ( :downcase ) sex_sort = trait . sex_name || 255 . chr stage_sort = trait . life_stage_name || '' stats_sort = trait . statistical_method? ? trait . statistical_methods . first . position : 65000 [ trait . predicate_uri . position , predicate , sex_sort , stats_sort , stage_sort , value_label ] end end
NOTE: Sorry this is complex, but: there are a lot of considerations for
sort!
NOTE : Sorry this is complex but : there are a lot of considerations for sort!
# NOTE: it's possible to have more than one, but we only care about first:
category
<not_specific>