-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Description
client <- connect()
search_content(client, limit = 2)With the above, I still get a full page's worth of results, not just 2. If I set the page size to a smaller value than the limit, then I get 2 items:
search_content(client, limit = 2, page_size = 1)I'd expect limit to work regardless of page_size.
The issue is that we fetch the first page of results here, bypass the while loop (because agg_length isn't less than limit), and then just return the whole page. We probably just want to subset agg_response[seq_len(min(limit, length(agg_response))] or something. [edit] or better eyt: set page_size to min(page_size, limit) before we make the API call.
Lines 73 to 96 in 73ce793
| agg_response <- res | |
| agg_length <- length(agg_response) | |
| while (length(res) > 0 && agg_length < limit && agg_length < total_items) { | |
| prg$tick() | |
| # bump the page number | |
| current_page <- req_response$current_page | |
| new_expr <- qexpr | |
| new_expr$page_number <- current_page + 1 | |
| new_req <- rlang::quo_set_expr(qreq, new_expr) | |
| # next request | |
| req_response <- rlang::eval_tidy(new_req) | |
| res <- req_response$results | |
| agg_response <- c(agg_response, res) | |
| agg_length <- length(agg_response) | |
| # clear out variables | |
| current_page <- NULL | |
| new_expr <- NULL | |
| new_req <- NULL | |
| } | |
| return(agg_response) |
Metadata
Metadata
Assignees
Labels
No labels