diff --git a/app/classes/inat_obs.rb b/app/classes/inat_obs.rb index 45474bbe80..050c03ff22 100644 --- a/app/classes/inat_obs.rb +++ b/app/classes/inat_obs.rb @@ -222,9 +222,7 @@ def lng end def sequences - obs_sequence_fields = - inat_obs_fields.keep_if { |f| sequence_field?(f) } - + obs_sequence_fields = inat_obs_fields.select { |f| sequence_field?(f) } obs_sequence_fields.each_with_object([]) do |field, ary| # TODO: 2024-06-19 jdc. Need more investigation/test to handle # field[:value] blank or not a (pure) lists of bases @@ -297,7 +295,7 @@ def description def sequence_field?(field) field[:datatype] == "dna" || - field[:name] =~ /DNA/ + field[:name] =~ /DNA/ && field[:value] =~ /^[ACTG]{,10}/ end def fungi? diff --git a/app/controllers/observations/inat_imports_controller.rb b/app/controllers/observations/inat_imports_controller.rb index 7ea5a56b1e..f96d0ae2ef 100644 --- a/app/controllers/observations/inat_imports_controller.rb +++ b/app/controllers/observations/inat_imports_controller.rb @@ -343,35 +343,6 @@ def adjust_consensus_name_naming end end - def add_inat_summmary_data(inat_obs) - params = { - target: @observation, - summary: "#{:inat_data_comment.t} #{@observation.created_at}", - comment: comment(inat_obs), - user: inat_manager - } - - Comment.create(params) - end - - def comment(inat_obs) - <<~COMMENT.gsub(/^\s+/, "") - #{:USER.t}: #{inat_obs.inat_user_login} - #{:OBSERVED.t}: #{inat_obs.when}\n - #{:LAT_LON.t}: #{lat_lon_accuracy(inat_obs)}\n - #{:PLACE.t}: #{inat_obs.inat_place_guess}\n - #{:ID.t}: #{inat_obs.inat_taxon_name}\n - #{:DQA.t}: #{inat_obs.dqa}\n - #{:ANNOTATIONS.t}: #{:UNDER_DEVELOPMENT.t}\n - #{:PROJECTS.t}: #{inat_obs.inat_project_names}\n - #{:SEQUENCES.t}: #{:UNDER_DEVELOPMENT.t}\n - #{:OBSERVATION_FIELDS.t}: \n\ - - #{obs_fields(inat_obs.inat_obs_fields)}\n - #{:TAGS.t}: #{inat_obs.inat_tags.join(" ")}\n - COMMENT - end - def lat_lon_accuracy(inat_obs) "#{inat_obs.inat_location} " \ "+/-#{inat_obs.inat_public_positional_accuracy} m" @@ -402,5 +373,34 @@ def obs_fields(fields) "  #{field[:name]}: #{field[:value]}" end.join("\n") end + + def add_inat_summmary_data(inat_obs) + params = { + target: @observation, + summary: "#{:inat_data_comment.t} #{@observation.created_at}", + comment: comment(inat_obs), + user: inat_manager + } + + Comment.create(params) + end + + def comment(inat_obs) + <<~COMMENT.gsub(/^\s+/, "") + #{:USER.t}: #{inat_obs.inat_user_login} + #{:OBSERVED.t}: #{inat_obs.when}\n + #{:LAT_LON.t}: #{lat_lon_accuracy(inat_obs)}\n + #{:PLACE.t}: #{inat_obs.inat_place_guess}\n + #{:ID.t}: #{inat_obs.inat_taxon_name}\n + #{:DQA.t}: #{inat_obs.dqa}\n + #{:ANNOTATIONS.t}: #{:UNDER_DEVELOPMENT.t}\n + #{:PROJECTS.t}: #{inat_obs.inat_project_names}\n + #{:SEQUENCES.t}: #{:UNDER_DEVELOPMENT.t}\n + #{:OBSERVATION_FIELDS.t}: \n\ + + #{obs_fields(inat_obs.inat_obs_fields)}\n + #{:TAGS.t}: #{inat_obs.inat_tags.join(" ")}\n + COMMENT + end end end