Skip to content

Commit

Permalink
Update api limit value and add warning on exhaustion
Browse files Browse the repository at this point in the history
  • Loading branch information
rundel committed Mar 25, 2024
1 parent 7a5b907 commit f5d4bb2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

* Added support for GitHub's versioned REST API

* Increased the default value of `github_set_api_limit()` to 10,000.

* Any rest API request will now report if the request limit is reached via a warning.

# ghclass 0.2.1

* ghclass is now on [CRAN](https://CRAN.R-project.org/package=ghclass)!
Expand Down
4 changes: 2 additions & 2 deletions R/github_api_limit.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ NULL
#' @export
#'
github_get_api_limit = function() {
getOption("ghclass.api.limit", 1000L)
getOption("ghclass.api.limit", 10000L)
}

#' @rdname github_api_limit
#' @export
#'
github_set_api_limit = function(limit = 1000L) {
github_set_api_limit = function(limit = 10000L) {
arg_is_pos_int(limit)
options("ghclass.api.limit" = limit)

Expand Down
11 changes: 10 additions & 1 deletion R/util_github.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ ghclass_api_v3_req = function(
limit = NULL
}

suppressMessages(
res = suppressMessages(
gh::gh(
endpoint = endpoint,
...,
Expand All @@ -210,4 +210,13 @@ ghclass_api_v3_req = function(
# .progress = FALSE # TODO - giving an error for some reason
)
)

if (length(res) == limit) {
cli::cli_warn(
c("The number of results is equal to the limit set by {.fn github_set_api_limit},",
"consider increasing this limit and rerunning the previous function.")
)
}

res
}
2 changes: 1 addition & 1 deletion man/github_api_limit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5d4bb2

Please sign in to comment.