Skip to content

Commit 14f7487

Browse files
authored
chore: adjust parameters for search_content() (#455)
1 parent dc55d83 commit 14f7487

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

R/content.R

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,12 @@ get_content_packages <- function(content) {
14441444
#' @param include Comma-separated character string of values indicating additional
14451445
#' details to include in the response. Values can be `owner` and `vanity_url`;
14461446
#' both are included by default.
1447-
#' @param ... Extra arguments. Passing in `page_number` and `page_size` will
1448-
#' affect the internal pagination for Connect's content search API. Setting
1449-
#' `page_number` will change the page at which pagination *starts*, and
1450-
#' `page_size` will control the size of pages (max 500).
1447+
#' @param page_size The number of items to fetch per page. Maximum is 500.
1448+
#' @param limit Maximum number of items to return overall. Defaults to `Inf` (all items).
1449+
#' @param ... Additional query parameters passed to the API for future expansion.
1450+
#' Note: If you pass `page_number` here, it will affect the *starting* page
1451+
#' for pagination, but all subsequent pages will still be fetched. This is
1452+
#' usually not what you want.
14511453
#'
14521454
#' @return
14531455
#' A list containing sub-fields:
@@ -1585,6 +1587,8 @@ search_content <- function(
15851587
client,
15861588
q = NULL,
15871589
include = "owner,vanity_url",
1590+
page_size = 500,
1591+
limit = Inf,
15881592
...
15891593
) {
15901594
error_if_less_than(client$version, "2024.04.0")
@@ -1595,28 +1599,29 @@ search_content <- function(
15951599
client,
15961600
q = q,
15971601
include = include,
1598-
# page_size and page_number can be passed in via `...`. Since this call is
1599-
# still passed to page_offset, page_number affects the *starting* page,
1600-
# but pagination still continues.
1602+
page_size = page_size,
16011603
...
1602-
)
1604+
),
1605+
limit = limit
16031606
)
16041607
}
16051608

16061609
.search_content <- function(
16071610
client,
16081611
q,
1612+
include,
16091613
page_number = 1,
16101614
page_size = 500,
1611-
include
1615+
...
16121616
) {
16131617
path <- v1_url("search", "content")
16141618

16151619
query <- list(
16161620
q = q,
16171621
page_number = page_number,
16181622
page_size = page_size,
1619-
include = include
1623+
include = include,
1624+
...
16201625
)
16211626

16221627
client$GET(path, query = query)

man/search_content.Rd

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-content.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,24 @@ with_mock_dir("2025.09.0", {
496496
)
497497
})
498498

499-
test_that("content search passes all parameters through correctly", {
499+
test_that("content search uses default page_size of 500 and page_number of 1", {
500+
without_internet(
501+
expect_GET(
502+
search_content(client, q = "bream"),
503+
"https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner%2Cvanity_url" #nolint
504+
)
505+
)
506+
})
507+
508+
test_that("content search passes arbitrary parameters through ... to query string", {
500509
without_internet(
501510
expect_GET(
502511
search_content(
503512
client,
504513
q = "bream",
505-
page_number = 2,
506-
page_size = 20,
507-
include = "owner"
514+
future_param = "value"
508515
),
509-
"https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=20&include=owner"
516+
"https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner%2Cvanity_url&future_param=value" #nolint
510517
)
511518
)
512519
})

0 commit comments

Comments
 (0)