Skip to content

Commit

Permalink
Add issues MISSING_MATERIAL and MISSING_CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
joeroe committed Mar 23, 2023
1 parent a07d589 commit 06360eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/helpers/issues_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ def issue_description(issue)
when :missing_bibtex
"No bibliographical information recorded"
# Samples
when :missing_material
"Sample material is not recorded"
when :missing_taxon
"Taxonomic classification of the sample material is unknown"
"Taxonomic classification of the sample material is not recoreded"
when :missing_crs
"Coordinate reference system (CRS) of sample coordinates is not recorded"
# Taxons
when :unknown_taxon
"Taxon not matched to the GBIF Backbone Taxonomy"
Expand Down
23 changes: 19 additions & 4 deletions app/models/sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,29 @@ class Sample < ApplicationRecord
acts_as_copy_target # enable CSV exports

include HasIssues
@issues = [ :missing_taxon ]

@issues = [ :missing_material, :missing_taxon, :missing_crs ]

def self.label
"sample"
end

# Issues
scope :missing_material, -> { where(material_id: nil) }
def missing_material?
material.blank?
end

scope :missing_taxon, -> { where(taxon_id: nil) }
def missing_taxon?
taxon.blank?
end

def self.label
"sample"
scope :missing_crs, -> { where('position_crs IS NULL AND (position_x IS NOT NULL OR position_y IS NOT NULL OR position_z IS NOT NULL)') }
def missing_crs?
if position_x.blank? and position_y.blank? and position_z.blank?
false
else
position_crs.blank?
end
end
end

0 comments on commit 06360eb

Please sign in to comment.