-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added search functionality to get_publications() #67
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few quick thoughts on this one
page_size = page_size, | ||
page = page, | ||
verbose = verbose | ||
) | ||
) |> | ||
httr::content("text") |> | ||
jsonlite::fromJSON() | ||
if (!is.null(search)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -10,6 +10,7 @@ | |||
get_publications <- function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a search example into the examples for roxygen2
@@ -14,6 +14,7 @@ | |||
#' | |||
#' @param endpoint Name of endpoint, can be "get-publications", "get-data-catalogue", | |||
#' "get-summary", "get-meta", "get-csv", "get-data" or "post-data" | |||
#' @param search String for filtering publication list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth specifying that it filters by the publication title?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the first test in this script to just check it returns more than 1 row now? Would be good to move away from it being exactly matching the live data as that will be hard to track over time.
Alternative, maybe we set it up against somewhere like test explicitly and then check that specific test data files we've added are in there or something?
@@ -124,7 +126,12 @@ api_url <- function( | |||
url <- paste0( | |||
endpoint_base_version, | |||
"publications?", | |||
api_url_pages(page_size = page_size, page = page) | |||
api_url_pages(page_size = page_size, page = page), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_that("Search works as expected", { | ||
expect_equal( | ||
get_publications(search = "API") |> | ||
dplyr::filter(!grepl("API", title)) |> | ||
nrow(), | ||
0 | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test would also pass if the API call returned no rows (without testing the search at all), are we okay with that?
Brief overview of changes
Added the search parameter as an option in get_publications()
Why are these changes being made?
Missing functionality.
Detailed description of changes
Just changes in
get_publications()
andapi_url()
to add in the search parameter, plus some validation and testing.Additional information for reviewers
Issue ticket number/s and link
Closes #61