fix: add acceptedUsageKey and acceptedScientificName to name_backbone…#826
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for returning acceptedUsageKey and acceptedScientificName fields from the name_backbone function to handle taxonomic synonyms. When the GBIF API returns a synonym, these fields provide information about the accepted/valid name for the taxon. This addresses issue #824.
- Extracts
acceptedUsagedata from the GBIF species match API v2 response - Adds test coverage for the new fields using a synonym example (Anastrophyllum minutum)
- Increments package version from 3.8.4.1 to 3.8.4.2
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| R/name_backbone.r | Adds processing logic to extract acceptedUsageKey and acceptedScientificName from API response |
| tests/testthat/test-name_backbone.r | Adds test to verify the new fields are returned |
| tests/fixtures/name_backbone_acceptedUsageKey.yml | Provides VCR cassette with API response containing synonym and acceptedUsage data |
| DESCRIPTION | Bumps version to 3.8.4.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect_true("acceptedUsageKey" %in% colnames(aa)) | ||
| expect_true("acceptedScientificName" %in% colnames(aa)) |
There was a problem hiding this comment.
The test verifies that the columns exist but doesn't check their actual values. Based on the fixture data, the test should verify that acceptedUsageKey is "2689422" and acceptedScientificName is "Sphenolobus minutus (Schreb. ex Cranz) Berggr." to ensure the function correctly extracts these values from the API response.
| a <- tibble::as_tibble(tt$acceptedUsage)[c("key","name")] | ||
| colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey" | ||
| colnames(a)[colnames(a) == "name"] <- "acceptedScientificName" |
There was a problem hiding this comment.
The acceptedUsage processing subsets only the "key" and "name" fields, which is inconsistent with how the usage object is processed (lines 231-235). The usage processing converts the entire object to a tibble and then renames specific columns. Consider following the same pattern here: convert the entire acceptedUsage object to a tibble first, then rename the columns, to maintain consistency and allow any additional fields from the API to be included.
| a <- tibble::as_tibble(tt$acceptedUsage)[c("key","name")] | |
| colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey" | |
| colnames(a)[colnames(a) == "name"] <- "acceptedScientificName" | |
| a <- tibble::as_tibble(tt$acceptedUsage) | |
| if ("key" %in% colnames(a)) colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey" | |
| if ("name" %in% colnames(a)) colnames(a)[colnames(a) == "name"] <- "acceptedScientificName" |
- Update version from 3.8.4.5 to 3.8.5 - Add NEWS.md changelog for v3.8.5 - Document 6 new download statistics functions (#837) - Document multiple taxonomy downloads support (#832) - Document verbatim extension downloads support (#831) - Document bug fixes for name_backbone functions (#822, #826) - Document removal of wk dependency (#828) - Document documentation improvements (#836)
* Prepare v3.8.5 release - Update version from 3.8.4.5 to 3.8.5 - Add NEWS.md changelog for v3.8.5 - Document 6 new download statistics functions (#837) - Document multiple taxonomy downloads support (#832) - Document verbatim extension downloads support (#831) - Document bug fixes for name_backbone functions (#822, #826) - Document removal of wk dependency (#828) - Document documentation improvements (#836) * Fix broken BasisOfRecord documentation URL - Replace broken GBIF parsers URL with Darwin Core standard URL - Update man-roxygen/occsearch.r template - Update inline documentation in R/occ_data.R - Resolves CRAN incoming feasibility NOTE * REVDEPCHECK * updating codemeta
#824