Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated endpoint list #37

Merged
merged 19 commits into from
Dec 10, 2024
Merged

updated endpoint list #37

merged 19 commits into from
Dec 10, 2024

Conversation

mustberuss
Copy link
Collaborator

Endpoints are now singular and some are nested under patent/ and one is nested under publication

@mustberuss mustberuss marked this pull request as draft November 30, 2024 13:20
@mustberuss mustberuss marked this pull request as ready for review November 30, 2024 15:48
@crew102
Copy link
Collaborator

crew102 commented Dec 5, 2024

Hey Russ, a few questions on this:

  • Do we need to have the to_singular and to_plural functions anymore, given that they're not used anywhere (from what I can see)
  • Can we just do something like this instead of listing all the endpoints, to dry out the code a little:
get_endpoints <- function() {
  unique(fieldsdf$endpoint)
}
  • Were updates to the test queries included in this PR for any particular reason? Asking b/c I see plural endpoint names elsewhere in the codebase still and didn't know if I missed something.

@mustberuss
Copy link
Collaborator Author

You're right on the singular/plural functions, they aren't needed any longer. Nice catch.

We can dry out get_endpoints(), but could we put a sort() around it? Or is that covered by the arrange in fieldsdf.R? I like having the ones nested under patent traveling together!

The tests were included to get the builds back to working. I'm guessing the failing tests are keeping it off r-universe. Still having plural endpoints wasn't intentional.

@mustberuss
Copy link
Collaborator Author

Looks like we do need to_plural() to handle groups in the code I just pushed. In fieldsdf now the group on an unnested field is an empty string (""). Previously the group matched the endpoint when they were plural and unnested. Now the API throws an error if an unnested field is fully qualified, e.g. Error: Invalid field: patents.patent_date

The alternative is to have an empty string as a group mean unnested fields but that doesn't seem ideal. Using the actual returned entity seems less wrong though I don't like that users need to know the ipc endpoint's returned entity is ipcr and wipo returns wipo (the rest are the plural of the de-nested endpoint).

I was wrong about getting the tests to pass. They'll need changes to search-pv that I was planning to do in a later PR. I was trying to keep this one to the specifics of the endpoint changes in the code. I think I got rid of all the plural endpoints now, except for the vignettes.

@crew102
Copy link
Collaborator

crew102 commented Dec 6, 2024

Hey Russ, sorry not sure I'm following. What's wrong with this version of the code:

get_fields <- function(endpoint, groups = NULL) {
  browser()
  # validate_endpoint(endpoint)
  if (is.null(groups)) {
    fieldsdf[fieldsdf$endpoint == endpoint, "field"]
  } else {
    # groups <- replace(groups, groups == to_plural(endpoint), "")
    # validate_groups(endpoint, groups = groups)
    fieldsdf[fieldsdf$endpoint == endpoint & fieldsdf$group %in% groups, "field"]
  }
}

@mustberuss
Copy link
Collaborator Author

With the change in fieldsdf.R, top level/unnested attributes don't have a group filled in in fieldsdf, it's an empty string now. They can't be requested with a group as the nested fields are. In the example code the group of "assignees" works since there is a group of assignees in the data frame for the patent endpoint but there isn't a group of patents for the patent endpoints.

#' # Get all patent and assignee-level fields for the patent endpoint:
get_fields(endpoint = "patent", groups = c("assignees", "patents"))

# with snippage
#>  [7] "assignees.assignee_sequence"                                 
#>  [8] "assignees.assignee_state"                                    
#>  [9] "assignees.assignee_type"                                     
#> [10] "gov_interest_statement"                                      
#> [11] "patent_abstract"                                             
#> [12] "patent_cpc_current_group_average_patent_processing_days"     
#> [13] "patent_date"           

@mustberuss
Copy link
Collaborator Author

Probably the better fix would be to put to_plural() in fieldsdf.R and populate the group with to_plural(endpoint) for unnested attributes and use the original code in get_fields(). Should we do that here or in a separate PR?

group = "",

Only problem with that is it negates my best PR 😃

@mustberuss
Copy link
Collaborator Author

Or I could let go of to_plural() and change fieldsdf.R since the plural entity is in openapi.json!

group = names(api$components$schemas[[schema_element]]$properties)

@crew102
Copy link
Collaborator

crew102 commented Dec 10, 2024

Thanks!

@crew102 crew102 closed this Dec 10, 2024
@crew102 crew102 reopened this Dec 10, 2024
@crew102 crew102 merged commit e0ebd97 into ropensci:master Dec 10, 2024
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants