Skip to content

feat: return a list of Content class objects from search_content()#463

Merged
toph-allen merged 2 commits intomainfrom
toph/search_content-content-class
Oct 16, 2025
Merged

feat: return a list of Content class objects from search_content()#463
toph-allen merged 2 commits intomainfrom
toph/search_content-content-class

Conversation

@toph-allen
Copy link
Contributor

@toph-allen toph-allen commented Oct 14, 2025

Intent

Instead of returning a list of lists from search_content(), return a list of Content class objects. This allows users to use existing content-related functions with the list via purrr.

Fixes #452
Fixes #448

Approach

This is pretty minimal so far — just changing the class of the returned object.

Using purrr to act upon the list of content is not an ideal workflow, but this is the first step towards something more user-friendly. See the original issue.

Documentation is not ideal. The Connect class does not document available fields, and the fields documented on get_content() are out of date. I filed #461 to track this.

Checklist

  • Does this change update NEWS.md (referencing the connected issue if necessary)? [Not needed]
  • Does this change need documentation? Have you run devtools::document()?

Copy link

@marcosnav marcosnav left a comment

Choose a reason for hiding this comment

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

Looks good!

@toph-allen toph-allen merged commit b55a81b into main Oct 16, 2025
21 checks passed
@toph-allen toph-allen deleted the toph/search_content-content-class branch October 16, 2025 18:20
Comment on lines +1525 to +1529
#' my_content <- search_content(client, q = "owner:@me")
#'
#' shiny_content <- purrr::keep(my_content, function(x) {
#' x$content$app_mode == "rmd-shiny"
#' })
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit of an odd example, no? I suspect it's there to show that (currently) one should use purrr::keep(...) for filtering, but in this case, you would actually want to do my_content <- search_content(client, q = "owner:@me type:rmd-shiny") to do this.

There's an arc of work to make the list more-easily-filterable that we should take up (later/next), but IMO we should document the stuff we're building now with how it should be used today, even if there might be other ways to do / other tasks folks might do with stuff like this in the future.

Copy link
Contributor Author

@toph-allen toph-allen Oct 16, 2025

Choose a reason for hiding this comment

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

Good point!! Perhaps I should use the longer example I used in GitHub PRs that uses a comparison that isn't possible in the filter API at the moment.

[edit] And/or just remove this example.

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.

search_content() function could return a list of Content class objects feat: Add better printing to the output of search_content()

3 participants