Module: TaxonWorks::Analysis::AssertedDistribution::BasicEndemism
- Defined in:
- lib/taxonworks/analysis/asserted_distribution/basic_endemism.rb
Class Method Summary collapse
-
.quick_endemism(taxon_name, geographic_area) ⇒ Hash
A very simple report summarizing asserted distributions !! only a single geographic area is used (not its children).
Class Method Details
.quick_endemism(taxon_name, geographic_area) ⇒ Hash
Returns a very simple report summarizing asserted distributions !! only a single geographic area is used (not its children).
11 12 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 |
# File 'lib/taxonworks/analysis/asserted_distribution/basic_endemism.rb', line 11 def self.quick_endemism(taxon_name, geographic_area) data = {} otus = Otu.descendant_of_taxon_name(taxon_name.id) return {} if otus.count > 2000 q = ::Queries::AssertedDistribution::Filter.new( taxon_name_id: taxon_name.id, descendants: true, geographic_area: ) return {} if q.all.select(:otu_id).distinct.count > 2000 q.all.find_each do |a| e = ::AssertedDistribution.where(project: taxon_name.project, otu_id: a.otu_id).where.not(geographic_area:).count n = a.otu.taxon_name&.valid_taxon_name if e == 0 && !data[n] data[n] = false else data[n] = true end end data end |