app/models/taxon_concept.rb
# NOTE - this filters out results with no name, no language, languages with no
# iso_639_1, and dulicates within the same language. Then it sorts the
# results. TODO - rename it to make the filtering and sorting more clear.
this filters out results with no name, no language, languages with no
iso_639_1, and dulicates within the same language. Then it sorts the
results. TODO - rename it to make the filtering and sorting more clear.
this filters out results with no name no language languages with no iso_639_1 and dulicates within the same language . Then it sorts the results . TODO - rename it to make the filtering and sorting more clear .
def common_names(options = {})
    @common_names = if options[:hierarchy_entry_id]
      TaxonConceptName.joins(:name, :language).where(source_hierarchy_entry_id: options[:hierarchy_entry_id])
    else
      taxon_concept_names.joins(:name, :language)
    end
    @common_names = @common_names.where("vern = 1 AND languages.iso_639_1 IS NOT NULL AND languages.iso_639_1 != ''").
      includes([ :language, :name ]).order('taxon_concept_names.language_id ASC, taxon_concept_names.preferred DESC')
    duplicate_check = {}
    @common_names = @common_names.select do |tcn|
      key = "#{tcn.language.iso_639_1}:#{tcn.name.string}"
      keep = !duplicate_check[key]
      duplicate_check[key] = true
      keep
    end
    TaxonConceptName.sort_by_language_and_name(@common_names)
  end
def common_names ( options = { } ) @common_names = if options [ :hierarchy_entry_id ] TaxonConceptName . joins ( :name , :language ) . where ( source_hierarchy_entry_id : options [ :hierarchy_entry_id ] ) else taxon_concept_names . joins ( :name , :language ) end @common_names = @common_names . where ( "vern = 1 AND languages.iso_639_1 IS NOT NULL AND languages.iso_639_1 != ''" ) . includes ( [ :language , :name ] ) . order ( 'taxon_concept_names.language_id ASC, taxon_concept_names.preferred DESC' ) duplicate_check = { } @common_names = @common_names . select do | tcn | key = "#{tcn.language.iso_639_1}:#{tcn.name.string}" keep = ! duplicate_check [ key ] duplicate_check [ key ] = true keep end TaxonConceptName . sort_by_language_and_name ( @common_names ) end
NOTE - this filters out results with no name, no language, languages with no
iso_639_1, and dulicates within the same language.
NOTE - this filters out results with no name no language languages with no iso_639_1 and dulicates within the same language .
# remove duplicate names in the same language:
options
<not_specific>