posit-dev / posit-dev/connectapi
Make it easier to apply existing `Content` functions to lists of content
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 54
- Forks
- 27
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 1
Description
#463 (in flight at time of writing) modifies search_content() to return a list of Connect class objects.
Right now, the best way to call existing functions that operate on Content class objects is to use purrr::map(). This is pretty simple if there are no additional arguments passed, but if additional args were required, you'd have to use R's anonymous function syntax.
# Assume `old_content` is a list of content class objects that need to be locked.
length(old_content)
# [1] 48
# Use purrr::map to apply existing functions to the list.
old_content <- purrr::map(old_content, lock_content)
# When passing extra args
old_content <- purrr::map(old_content, \(x) lock_content(x, locked_message = "R version is too old."))
It would be nicer if you could just pass the list to the functions and have it work, like so:
old_content <- lock_content(old_content, locked_message = "R version is too old.")
This might require us modifying all the content functions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read issue #463's change to search_content() and inspect the existing functions that operate on Content objects; no file or test is named here. Define how list inputs and additional arguments should behave, then verify that calls such as lock_content(old_content, locked_message = "R version is too old.") match the purrr::map() result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100