Module: Tasks::Gis::OtuDistributionDataHelper

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

Instance Method Summary collapse

Instance Method Details

#distribution_previous_next(object, type, distribution = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 17

def distribution_previous_next(object, type, distribution = nil)
  case type
  when 'Otu'
    (:span, (previous_otu_distribution_link(object, distribution) + ' | ' + next_otu_distribution_link(object, distribution)).html_safe)
  when 'Taxon name'
    (:span, (previous_taxon_name_distribution_link(object) + ' | ' + next_taxon_name_distribution_link(object)).html_safe)
  end
  
end


43
44
45
46
47
48
49
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 43

def next_otu_distribution_link(otu, distribution)
  if id = Otu.where("id > #{distribution.otus.first.id}").with_project_id(sessions_current_project_id).order(id: :asc).limit(1).pluck(:id).first 
    link_to 'Next', otu_distribution_data_task_url(otu_id: id)
  else
    'Next'
  end 
end


27
28
29
30
31
32
33
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 27

def next_taxon_name_distribution_link(taxon_name)
  if id =  TaxonName.where("id > #{taxon_name.id}").with_project_id(sessions_current_project_id).order(id: :asc).limit(1).pluck(:id).first
    link_to 'Next', otu_distribution_data_task_url(taxon_name_id: id)
  else
    'Next'
  end
end

#otu_aggregation(otu) ⇒ Object



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

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


51
52
53
54
55
56
57
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 51

def previous_otu_distribution_link(otu, distribution)
  if id = Otu.where("id < #{distribution.otus.first.id}").with_project_id(sessions_current_project_id).order(id: :desc).limit(1).pluck(:id).first
  link_to 'Previous', otu_distribution_data_task_url(otu_id: id)
  else
    'Previous'
  end
end


35
36
37
38
39
40
41
# File 'app/helpers/tasks/gis/otu_distribution_data_helper.rb', line 35

def previous_taxon_name_distribution_link(taxon_name)
  if id = TaxonName.where("id < #{taxon_name.id}").with_project_id(sessions_current_project_id).order(id: :desc).limit(1).pluck(:id).first
    link_to 'Previous', otu_distribution_data_task_url(taxon_name_id: id) 
  else
    'Previous'
  end 
end

#without_shape?(distributions) ⇒ Boolean

Returns:

  • (Boolean)


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

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