Module: Tasks::Gis::OtuDistributionDataHelper

Defined in:
app/helpers/tasks/gis/otu_distribution_data_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) forward_back_taxon_name_distribution(taxon_name)



16
17
18
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 16

def forward_back_taxon_name_distribution(taxon_name)
  (:span, (previous_taxon_name_distribution(taxon_name) + ' | ' + next_taxon_name_distribution(taxon_name)).html_safe)
end

- (Object) next_taxon_name_distribution(taxon_name)



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 41

def next_taxon_name_distribution(taxon_name)
  # next_link(taxon_name)
  # new_taxon_name = TaxonName.order(id: :asc).with_project_id(taxon_name.project_id).where('id > ?', taxon_name.id).limit(1).first
  # link_to('next', "#{new_taxon_name_id}")
  text = 'Next'
  # if taxon_name.respond_to?(:project_id)
  # link_object = taxon_name.class.base_class.order(id: :asc).with_project_id(sessions_current_project_id).where(['id > ?', taxon_name.id]).limit(1).pluck(:id).first
  # fail
  case @type_tag
    when 'Otu'
      link_object = Otu.with_project_id(sessions_current_project_id).order(id: :asc).where("id > #{@distribution.otus.first.id}").limit(1).pluck(:id).first
    when 'Taxon name'
      link_object = TaxonName.with_project_id(sessions_current_project_id).order(id: :asc).where("id > #{taxon_name.id}").limit(1).pluck(:id).first
    else
  end
  # else
  #   link_object = taxon_name.class.base_class.order(id: :asc).where(['id > ?', taxon_name.id]).limit(1).first
  # end
  link_object.nil? ? text : link_to(text, "#{link_object}")
end

- (Object) otu_aggregation(otu)



2
3
4
5
6
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 2

def otu_aggregation(otu)
  retval                      = otu.distribution_geoJSON
  retval['properties']['tag'] = object_tag(otu)
  retval
end

- (Object) previous_taxon_name_distribution(taxon_name)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 20

def previous_taxon_name_distribution(taxon_name)
  # next_link(taxon_name)
  # new_taxon_name_id = TaxonName.order(id: :desc).with_project_id(taxon_name.project_id).where('id < ?', taxon_name.id).limit(1).pluck(:id).first
  # link_to('previous', "#{new_taxon_name_id}")
  text = 'Previous'
  # if taxon_name.respond_to?(:project_id)
  # link_object = taxon_name.class.base_class.order(id: :desc).with_project_id(sessions_current_project_id).where(['id < ?', taxon_name.id]).limit(1).pluck(:id).first
  case @type_tag
    when 'Otu'
      link_object = Otu.with_project_id(sessions_current_project_id).order(id: :desc).where("id < #{@distribution.otus.first.id}").limit(1).pluck(:id).first
    when 'Taxon name'
      link_object = TaxonName.with_project_id(sessions_current_project_id).order(id: :desc).where("id < #{taxon_name.id}").limit(1).pluck(:id).first
    else
  end
  # else
  #   link_object = taxon_name.class.base_class.order(id: :desc).where(['id < ?', taxon_name.id]).limit(1).first
  # end
  # fail
  link_object.nil? ? text : link_to(text, "#{link_object}")
end

- (Boolean) without_shape?(distributions)

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 8

def without_shape?(distributions)
  count = 0
  distributions.each { |dist|
    count += 1 if dist.geographic_area.geographic_items.count == 0
  }
  ", #{count} without shape" if count > 0
end