diff --git a/app/classes/inat_taxon.rb b/app/classes/inat_taxon.rb index 1bda2c0d75..385cee4381 100644 --- a/app/classes/inat_taxon.rb +++ b/app/classes/inat_taxon.rb @@ -15,11 +15,7 @@ def initialize(inat_taxon) end def name - mo_names = Name.where(text_name: @inat_taxon[:name], - rank: @inat_taxon[:rank].titleize). - # iNat doesn't have taxon names "sensu xxx" - # so don't map them to MO Names sensu xxx - where.not(Name[:author] =~ /^sensu /) + mo_names = matching_mo_names return Name.unknown if mo_names.none? return mo_names.first if mo_names.one? @@ -30,4 +26,28 @@ def name # - might need a dictionary here Name.unknown end + + ######### + + private + + def matching_mo_names + return matching_complexes if complex? + + Name.where(text_name: @inat_taxon[:name], + rank: @inat_taxon[:rank].titleize). + # iNat doesn't have taxon names "sensu xxx" + # so don't map them to MO Names sensu xxx + where.not(Name[:author] =~ /^sensu /) + end + + def complex? + @inat_taxon[:rank] == "complex" + end + + def matching_complexes + # text_names of MO groups include "group" or the like + Name.where(Name[:text_name] =~ /^#{@inat_taxon[:name]}/). + where(rank: "Group") + end end diff --git a/app/controllers/observations/inat_imports_controller.rb b/app/controllers/observations/inat_imports_controller.rb index 879f825b53..7ea5a56b1e 100644 --- a/app/controllers/observations/inat_imports_controller.rb +++ b/app/controllers/observations/inat_imports_controller.rb @@ -304,21 +304,7 @@ def add_namings(inat_obs) user: user, value: 0).save end - naming = Naming.find_by(observation: @observation, - name: @observation.name) - - if naming.nil? - naming = Naming.new(observation: @observation, - user: inat_manager, - name: @observation.name) - naming.save - Vote.new(naming: naming, observation: @observation, - user: inat_manager, value: 1).save - else - vote = Vote.find_by(naming: naming, observation: @observation) - vote.value = 1 - vote.save - end + adjust_consensus_name_naming end def name_already_proposed?(name) @@ -339,6 +325,24 @@ def naming_user(identification) end end + def adjust_consensus_name_naming + naming = Naming.find_by(observation: @observation, + name: @observation.name) + + if naming.nil? + naming = Naming.new(observation: @observation, + user: inat_manager, + name: @observation.name) + naming.save + Vote.new(naming: naming, observation: @observation, + user: inat_manager, value: 1).save + else + vote = Vote.find_by(naming: naming, observation: @observation) + vote.value = 1 + vote.save + end + end + def add_inat_summmary_data(inat_obs) params = { target: @observation, diff --git a/test/inat/README_INAT_EXAMPLES.md b/test/inat/README_INAT_EXAMPLES.md index d6558d8616..d643610cd1 100644 --- a/test/inat/README_INAT_EXAMPLES.md +++ b/test/inat/README_INAT_EXAMPLES.md @@ -20,7 +20,7 @@ All data as of the time of importing. (The corresponding iNat Observation may ha | calostoma_lutescens.txt | [195434438](https://www.inaturalist.org/observations/195434438) | **0** | public | | | ceanothus_cordulatus.txt | [219631412](https://www.inaturalist.org/observations/219631412) | 1 | public | **Plant** | | coprinus.txt | [213450312](https://www.inaturalist.org/observations/213450312) | 1 | **obscured** | Needs ID | -| donadina_PNW01.txt | [212320801](https://www.inaturalist.org/observations/212320801) | 1 | public | **non-mo-style Provisional Species Name**, **DNA** | +| donadina_PNW01.txt | [212320801](https://www.inaturalist.org/observations/212320801) | 1 | public | **non-mo-style Provisional Species Name (PNW)**, **DNA** | | evernia.txt | [216357655](https://www.inaturalist.org/observations/216357655) | 0 | public | Casual, lichen, no fields, place: Troutdale | | fuligo_septica.txt | [219783802](https://www.inaturalist.org/observations/219783802) | 1 | public | slime mold **Protozoa** Richmond, CA | | gyromitra_ancilis.txt | [216745568](https://www.inaturalist.org/observations/216745568) | 3 | public | **cc-by license**, **many projects**, US 20, Linn Co.| @@ -34,6 +34,7 @@ All data as of the time of importing. (The corresponding iNat Observation may ha | somion_unicolor.txt | [**202555552**](https://www.inaturalist.org/observations/202555552) | 5 | public | Research Grade, Notes, Activity, >1 ID, 1 field (Mushroom Observer URL), **mirrored from MO** | | trametes.txt | [220370929](https://www.inaturalist.org/observations/220370929) | 2 | public | D. Miller observation with different collector; Notes; **Observation Fields: Collector**, place: 25th Ave NE, Seattle, WA, US, with huge error | | tremella_mesenterica.txt | [213508767](https://www.inaturalist.org/observations/213508767) | 1 | public | place: Lewisville, TX 75057, USA | +| xeromphalina_campanella_complex.txt | [215969102](https://www.inaturalist.org/observations/215969102) | 2 | public | **Complex** | | zero_results.txt | n.a. | | n.a. | response with total_results: 0, to expose and prevent reversion of bug | ## TODO diff --git a/test/inat/xeromphalina_campanella_complex.txt b/test/inat/xeromphalina_campanella_complex.txt new file mode 100644 index 0000000000..15dbc7abb0 --- /dev/null +++ b/test/inat/xeromphalina_campanella_complex.txt @@ -0,0 +1 @@ +{"total_results":1,"page":1,"per_page":30,"results":[{"quality_grade":"needs_id","time_observed_at":null,"taxon_geoprivacy":null,"annotations":[],"uuid":"b46f6a82-b2cc-470a-82a2-9cee0869c1c5","observed_on_details":{"date":"2024-03-25","day":25,"month":3,"year":2024,"hour":0,"week":13},"id":215969102,"cached_votes_total":0,"identifications_most_agree":false,"created_at_details":{"date":"2024-05-15","day":15,"month":5,"year":2024,"hour":12,"week":20},"species_guess":"Xeromphalina campanella","identifications_most_disagree":false,"tags":[],"positional_accuracy":20,"comments_count":0,"site_id":1,"created_time_zone":"America/Los_Angeles","license_code":"cc-by-nc","observed_time_zone":"America/Los_Angeles","quality_metrics":[],"public_positional_accuracy":20,"reviewed_by":[260453],"oauth_application_id":806,"flags":[],"created_at":"2024-05-15T12:23:39-07:00","description":"Originally posted to Mushroom Observer on Mar. 25, 2024.","time_zone_offset":"-08:00","project_ids_with_curator_id":[],"observed_on":"2024-03-25","observed_on_string":"2024-03-25","updated_at":"2024-05-15T12:24:01-07:00","sounds":[],"place_ids":[1,10,536,9853,50422,59613,64421,64429,65360,65818,66741,67725,81864,92151,92665,96683,97394,111581,117097,119138,119925,122420,126432,133787,133966,152384,154697],"captive":false,"taxon":{"is_active":true,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516/1529293/56253/1101286","min_species_ancestry":"48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848","endemic":false,"iconic_taxon_id":47170,"min_species_taxon_id":1366848,"threatened":false,"rank_level":11,"introduced":false,"native":false,"parent_id":1101286,"name":"Xeromphalina campanella","rank":"complex","extinct":false,"id":1366848,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848],"created_at":"2022-03-21T19:45:07+00:00","default_photo":null,"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":34,"photos_locked":false,"universal_search_rank":34,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi"},"ident_taxon_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848],"outlinks":[],"faves_count":0,"ofvs":[{"id":27142290,"uuid":"0da94c05-5fb7-44bc-9143-788fcd58b0f7","field_id":5005,"datatype":"text","name":"Mushroom Observer URL","name_ci":"Mushroom Observer URL","value":"http://mushroomobserver.org/547485","value_ci":"http://mushroomobserver.org/547485","user_id":260453,"user":{"id":260453,"login":"jdcohenesq","spam":false,"suspended":false,"created_at":"2016-06-17T00:32:01+00:00","login_autocomplete":"jdcohenesq","login_exact":"jdcohenesq","name":"","name_autocomplete":"","orcid":null,"icon":"https://static.inaturalist.org/attachments/users/icons/260453/thumb.jpg?1569617224","observations_count":2499,"identifications_count":730,"journal_posts_count":0,"activity_count":3229,"species_count":579,"annotated_observations_count":1,"universal_search_rank":2499,"roles":["app owner"],"site_id":1,"icon_url":"https://static.inaturalist.org/attachments/users/icons/260453/medium.jpg?1569617224"}}],"num_identification_agreements":0,"preferences":{"prefers_community_taxon":null},"comments":[],"map_scale":null,"uri":"https://www.inaturalist.org/observations/215969102","project_ids":[4639],"community_taxon_id":null,"geojson":{"type":"Point","coordinates":[-122.7013,45.3924]},"owners_identification_from_vision":false,"identifications_count":0,"obscured":false,"num_identification_disagreements":0,"geoprivacy":null,"location":"45.3924,-122.7013","votes":[],"spam":false,"user":{"id":260453,"login":"jdcohenesq","spam":false,"suspended":false,"created_at":"2016-06-17T00:32:01+00:00","site_id":1,"login_autocomplete":"jdcohenesq","login_exact":"jdcohenesq","name":"","name_autocomplete":"","orcid":null,"icon":"https://static.inaturalist.org/attachments/users/icons/260453/thumb.jpg?1569617224","observations_count":2499,"identifications_count":730,"journal_posts_count":0,"activity_count":3229,"species_count":579,"annotated_observations_count":1,"universal_search_rank":2499,"roles":["app owner"],"icon_url":"https://static.inaturalist.org/attachments/users/icons/260453/medium.jpg?1569617224","preferences":{"prefers_observation_fields_by":"curators"}},"mappable":true,"identifications_some_agree":false,"project_ids_without_curator_id":[4639],"place_guess":"Cooks Butte Park, Lake Oswego, Clackamas Co., Oregon, USA","non_traditional_projects":[{"project_id":51022},{"project_id":182852}],"identifications":[{"id":487543846,"uuid":"86f217e0-4875-4bd1-aa7d-71f8bc059bc9","user":{"id":260453,"login":"jdcohenesq","spam":false,"suspended":false,"created_at":"2016-06-17T00:32:01+00:00","login_autocomplete":"jdcohenesq","login_exact":"jdcohenesq","name":"","name_autocomplete":"","orcid":null,"icon":"https://static.inaturalist.org/attachments/users/icons/260453/thumb.jpg?1569617224","observations_count":2499,"identifications_count":730,"journal_posts_count":0,"activity_count":3229,"species_count":579,"annotated_observations_count":1,"universal_search_rank":2499,"roles":["app owner"],"site_id":1,"icon_url":"https://static.inaturalist.org/attachments/users/icons/260453/medium.jpg?1569617224"},"created_at":"2024-05-15T12:23:39-07:00","created_at_details":{"date":"2024-05-15","day":15,"month":5,"year":2024,"hour":12,"week":20},"body":"Xeromphalina campanella group proposed by Joe Cohen\nJoe Cohen: Promising\n = MO community vote 57%","category":"leading","current":true,"flags":[],"own_observation":true,"taxon_change":null,"vision":false,"disagreement":null,"previous_observation_taxon_id":1366848,"spam":false,"taxon_id":1366848,"hidden":false,"moderator_actions":[],"taxon":{"id":1366848,"rank":"complex","rank_level":11,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286],"is_active":true,"min_species_taxon_id":1366848,"name":"Xeromphalina campanella","parent_id":1101286,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516/1529293/56253/1101286","min_species_ancestry":"48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848","extinct":false,"created_at":"2022-03-21T19:45:07+00:00","default_photo":null,"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":34,"photos_locked":false,"universal_search_rank":34,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi","ancestors":[{"id":47170,"rank":"kingdom","rank_level":70,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170],"is_active":true,"name":"Fungi","parent_id":48460,"ancestry":"48460","extinct":false,"default_photo":{"id":260296784,"license_code":"cc-by-nc","attribution":"(c) chofungi, some rights reserved (CC BY-NC)","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/260296784/square.jpg","original_dimensions":{"height":1984,"width":1587},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/260296784/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/260296784/medium.jpg"},"taxon_changes_count":4,"taxon_schemes_count":2,"observations_count":12656715,"flag_counts":{"resolved":51,"unresolved":1},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"http://en.wikipedia.org/wiki/Fungus","complete_rank":"phylum","iconic_taxon_name":"Fungi","preferred_common_name":"Fungi Including Lichens"},{"id":47169,"rank":"phylum","rank_level":60,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169],"is_active":true,"name":"Basidiomycota","parent_id":47170,"ancestry":"48460/47170","extinct":false,"default_photo":{"id":160331738,"license_code":"cc-by-nc","attribution":"(c) Christine Young, some rights reserved (CC BY-NC), uploaded by Christine Young","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/160331738/square.jpg","original_dimensions":{"height":2048,"width":1562},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/160331738/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/160331738/medium.jpg"},"taxon_changes_count":8,"taxon_schemes_count":2,"observations_count":9017785,"flag_counts":{"resolved":3,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"http://en.wikipedia.org/wiki/Basidiomycota","iconic_taxon_name":"Fungi","preferred_common_name":"Basidiomycete Fungi"},{"id":492000,"rank":"subphylum","rank_level":57,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000],"is_active":true,"name":"Agaricomycotina","parent_id":47169,"ancestry":"48460/47170/47169","extinct":false,"default_photo":{"id":102914709,"license_code":"cc-by-nc","attribution":"(c) Meg Madden, some rights reserved (CC BY-NC), uploaded by Meg Madden","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/102914709/square.jpg","original_dimensions":{"height":2048,"width":1761},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/102914709/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/102914709/medium.jpg"},"taxon_changes_count":1,"taxon_schemes_count":0,"observations_count":8678296,"flag_counts":{"resolved":3,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"https://en.wikipedia.org/wiki/Agaricomycotina","iconic_taxon_name":"Fungi","preferred_common_name":"Higher Basidiomycetes"},{"id":50814,"rank":"class","rank_level":50,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814],"is_active":true,"name":"Agaricomycetes","parent_id":492000,"ancestry":"48460/47170/47169/492000","extinct":false,"default_photo":{"id":6993855,"license_code":"cc-by","attribution":"(c) Davide Puddu, some rights reserved (CC BY), uploaded by Davide Puddu","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/6993855/square.jpg","original_dimensions":{"height":533,"width":800},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/6993855/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/6993855/medium.jpg"},"taxon_changes_count":2,"taxon_schemes_count":2,"observations_count":8584189,"flag_counts":{"resolved":5,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"https://en.wikipedia.org/wiki/Agaricomycetes","iconic_taxon_name":"Fungi","preferred_common_name":"mushrooms, bracket fungi, puffballs, and allies"},{"id":1094814,"rank":"subclass","rank_level":47,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814],"is_active":true,"name":"Agaricomycetidae","parent_id":50814,"ancestry":"48460/47170/47169/492000/50814","extinct":false,"default_photo":{"id":7018635,"license_code":"cc-by","attribution":"(c) Davide Puddu, some rights reserved (CC BY), uploaded by Davide Puddu","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7018635/square.jpg","original_dimensions":{"height":533,"width":800},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7018635/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7018635/medium.jpg"},"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":5151471,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi"},{"id":47167,"rank":"order","rank_level":40,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167],"is_active":true,"name":"Agaricales","parent_id":1094814,"ancestry":"48460/47170/47169/492000/50814/1094814","extinct":false,"default_photo":{"id":7259109,"license_code":"cc-by-nc","attribution":"(c) brian_nz, some rights reserved (CC BY-NC), uploaded by brian_nz","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7259109/square.jpg","original_dimensions":{"height":1544,"width":1235},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7259109/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/7259109/medium.jpg"},"taxon_changes_count":5,"taxon_schemes_count":2,"observations_count":4486247,"flag_counts":{"resolved":2,"unresolved":1},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"https://en.wikipedia.org/wiki/Agaricales","iconic_taxon_name":"Fungi","preferred_common_name":"Common Gilled Mushrooms and Allies"},{"id":785516,"rank":"suborder","rank_level":37,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516],"is_active":true,"name":"Marasmiineae","parent_id":47167,"ancestry":"48460/47170/47169/492000/50814/1094814/47167","extinct":false,"default_photo":{"id":92762912,"license_code":"cc-by-nc","attribution":"(c) Carlene Cliver, some rights reserved (CC BY-NC), uploaded by Carlene Cliver","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/92762912/square.jpg","original_dimensions":{"height":2048,"width":1536},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/92762912/square.jpg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/92762912/medium.jpg"},"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":752652,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi"},{"id":1529293,"rank":"family","rank_level":30,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293],"is_active":true,"name":"Xeromphalinaceae","parent_id":785516,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516","extinct":false,"default_photo":{"id":1214886,"license_code":null,"attribution":"(c) Melissa Hutchison, all rights reserved, uploaded by Melissa Hutchison","url":"https://static.inaturalist.org/photos/1214886/square.","original_dimensions":{"height":1536,"width":2048},"flags":[],"square_url":"https://static.inaturalist.org/photos/1214886/square.","medium_url":"https://static.inaturalist.org/photos/1214886/medium."},"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":24011,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi"},{"id":56253,"rank":"genus","rank_level":20,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253],"is_active":true,"name":"Xeromphalina","parent_id":1529293,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516/1529293","extinct":false,"default_photo":{"id":144334257,"license_code":null,"attribution":"(c) Heather Elson, all rights reserved, uploaded by Heather Elson","url":"https://static.inaturalist.org/photos/144334257/square.jpg","original_dimensions":{"height":1039,"width":1518},"flags":[],"square_url":"https://static.inaturalist.org/photos/144334257/square.jpg","medium_url":"https://static.inaturalist.org/photos/144334257/medium.jpg"},"taxon_changes_count":0,"taxon_schemes_count":2,"observations_count":19469,"flag_counts":{"resolved":2,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"http://en.wikipedia.org/wiki/Xeromphalina","iconic_taxon_name":"Fungi"},{"id":1101286,"rank":"section","rank_level":13,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286],"is_active":true,"name":"Xeromphalina","parent_id":56253,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516/1529293/56253","extinct":false,"default_photo":{"id":26578433,"license_code":"cc-by-nc","attribution":"(c) Stephen Russell, some rights reserved (CC BY-NC), uploaded by Stephen Russell","url":"https://inaturalist-open-data.s3.amazonaws.com/photos/26578433/square.jpeg","original_dimensions":{"height":2048,"width":995},"flags":[],"square_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/26578433/square.jpeg","medium_url":"https://inaturalist-open-data.s3.amazonaws.com/photos/26578433/medium.jpeg"},"taxon_changes_count":1,"taxon_schemes_count":0,"observations_count":10823,"flag_counts":{"resolved":1,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":"https://en.wikipedia.org/wiki/Xeromphalina","iconic_taxon_name":"Fungi","preferred_common_name":"Xeromphalina sect. xeromphalina"}]},"previous_observation_taxon":{"id":1366848,"rank":"complex","rank_level":11,"iconic_taxon_id":47170,"ancestor_ids":[48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848],"is_active":true,"min_species_taxon_id":1366848,"name":"Xeromphalina campanella","parent_id":1101286,"ancestry":"48460/47170/47169/492000/50814/1094814/47167/785516/1529293/56253/1101286","min_species_ancestry":"48460,47170,47169,492000,50814,1094814,47167,785516,1529293,56253,1101286,1366848","extinct":false,"created_at":"2022-03-21T19:45:07+00:00","default_photo":null,"taxon_changes_count":0,"taxon_schemes_count":0,"observations_count":34,"photos_locked":false,"universal_search_rank":34,"flag_counts":{"resolved":0,"unresolved":0},"current_synonymous_taxon_ids":null,"atlas_id":null,"complete_species_count":null,"wikipedia_url":null,"iconic_taxon_name":"Fungi"}}],"project_observations":[{"id":95642187,"uuid":"99036aaa-aec9-43a6-9211-6df2b49dfa6f","project":{"id":4639},"user_id":null,"preferences":{"allows_curator_coordinate_access":false}}],"observation_photos":[{"id":355742144,"position":0,"uuid":"06e12c42-79c9-4e09-a90b-e6fee2073b75","photo_id":381894665,"photo":{"id":381894665,"license_code":"cc-by-nc","original_dimensions":{"width":1485,"height":2048},"url":"https://inaturalist-open-data.s3.amazonaws.com/photos/381894665/square.jpeg","attribution":"(c) jdcohenesq, some rights reserved (CC BY-NC)","flags":[],"moderator_actions":[],"hidden":false}},{"id":355742158,"position":1,"uuid":"0637f39f-97c3-4999-be5e-d9f2f81df8fd","photo_id":381894686,"photo":{"id":381894686,"license_code":"cc-by-nc","original_dimensions":{"width":2048,"height":1904},"url":"https://inaturalist-open-data.s3.amazonaws.com/photos/381894686/square.jpeg","attribution":"(c) jdcohenesq, some rights reserved (CC BY-NC)","flags":[],"moderator_actions":[],"hidden":false}}],"photos":[{"id":381894665,"license_code":"cc-by-nc","original_dimensions":{"width":1485,"height":2048},"url":"https://inaturalist-open-data.s3.amazonaws.com/photos/381894665/square.jpeg","attribution":"(c) jdcohenesq, some rights reserved (CC BY-NC)","flags":[],"moderator_actions":[],"hidden":false},{"id":381894686,"license_code":"cc-by-nc","original_dimensions":{"width":2048,"height":1904},"url":"https://inaturalist-open-data.s3.amazonaws.com/photos/381894686/square.jpeg","attribution":"(c) jdcohenesq, some rights reserved (CC BY-NC)","flags":[],"moderator_actions":[],"hidden":false}],"faves":[],"non_owner_ids":[]}]} \ No newline at end of file diff --git a/test/models/inat_taxon_test.rb b/test/models/inat_taxon_test.rb index 816c266304..ce7bd9e17b 100644 --- a/test/models/inat_taxon_test.rb +++ b/test/models/inat_taxon_test.rb @@ -18,6 +18,27 @@ def test_name_basic "Incorrect MO Name for iNat identification") end + def test_complex + user = rolf + x_campanella_group = Name.new( + rank: "Group", + text_name: "Xeromphalina campanella group", + search_name: "Xeromphalina campanella group", + display_name: "**__Xeromphalina campanella__** group", + sort_name: "Xeromphalina campanella group", + citation: "\"??Mycologia?? 107(6): 1270\":" \ + "https://www.tandfonline.com/doi/full/10.3852/15-087 (2017)", + user: user + ) + x_campanella_group.save + + mock_inat_obs = mock_observation("xeromphalina_campanella_complex") + inat_taxon = InatTaxon.new(mock_inat_obs.inat_taxon) + + assert_equal(x_campanella_group, inat_taxon.name, + "Incorrect MO Name for iNat community id") + end + ######## private