Module: TaxonWorks::Analysis::AssertedDistribution::BasicEndemism
- Defined in:
- lib/taxonworks/analysis/asserted_distribution/basic_endemism.rb
Class Method Summary collapse
-
.quick_endemism(taxon_name, shape_type, shape_id) ⇒ Hash
Name => not endemic boolean a very simple report summarizing asserted distributions !! only a single shape is used (i.e. a taxon endemic to a child of the given shape will not match).
Class Method Details
.quick_endemism(taxon_name, shape_type, shape_id) ⇒ Hash
Returns name => not endemic boolean a very simple report summarizing asserted distributions !! only a single shape is used (i.e. a taxon endemic to a child
of the given shape will not match).
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/taxonworks/analysis/asserted_distribution/basic_endemism.rb', line 13 def self.quick_endemism(taxon_name, shape_type, shape_id) data = {} otus = Otu.descendant_of_taxon_name(taxon_name.id) if otus.count > 2000 return { basic_endemism_error: 'Taxon name has too many descendants' } end q = ::Queries::AssertedDistribution::Filter.new( taxon_name_id: taxon_name.id, descendants: true, geo_shape_type: shape_type, geo_shape_id: shape_id, geo_mode: nil, # exact, asserted_distribution_object_type: 'Otu' ) return {} if q.all.select(:asserted_distribution_object_id).distinct.count > 2000 q.all.find_each do |a| e = ::AssertedDistribution .where(project: taxon_name.project) .where(asserted_distribution_object: a.asserted_distribution_object) .where(asserted_distribution_shape_type: shape_type) .where.not(asserted_distribution_shape_id: shape_id) .count n = a.asserted_distribution_object.taxon_name&.valid_taxon_name next if n.nil? if e == 0 && !data[n] data[n] = false else data[n] = true end end data end |