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

Added search functionality to get_publications() #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rmbielby
Copy link
Contributor

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() and api_url() to add in the search parameter, plus some validation and testing.

Additional information for reviewers

Issue ticket number/s and link

Closes #61

@rmbielby rmbielby added the enhancement Improvement to existing feature label Jan 22, 2025
@rmbielby rmbielby added this to the Mop up sweep milestone Jan 22, 2025
@rmbielby rmbielby requested a review from cjrace January 22, 2025 11:33
@rmbielby rmbielby self-assigned this Jan 22, 2025
@rmbielby rmbielby linked an issue Jan 22, 2025 that may be closed by this pull request
Copy link
Contributor

@cjrace cjrace left a 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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more general for the function as a whole rather than search, but could we add a nice message to return if there were no rows found? (Guessing it might be a lot more common if people are trying to search)

image

@@ -10,6 +10,7 @@
get_publications <- function(
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle the conversion of spaces?

image

Comment on lines +21 to +28
test_that("Search works as expected", {
expect_equal(
get_publications(search = "API") |>
dplyr::filter(!grepl("API", title)) |>
nrow(),
0
)
})
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_publications() - add search functionality
2 participants