Skip to content

Commit

Permalink
req_retry all slack 429 errors; closes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed May 14, 2024
1 parent dfd95dc commit c70e7af
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashboard
Title: What the Package Does (One Line, Title Case)
Version: 0.2.2.023
Version: 0.2.2.024
Authors@R:
person(given = "First",
family = "Last",
Expand Down
26 changes: 22 additions & 4 deletions R/editors-slack.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,32 @@ get_slack_editors_status <- function () {

u <- "https://slack.com/api/users.list"
headers <- list (Authorization = paste0 ("Bearer ", tok))
# req_retry is to avoid transitent 429 errors from Slack API requests via
# GitHub
req <- httr2::request (u) |>
httr2::req_headers ("Authorization" = headers) |>
httr2::req_method ("GET")
httr2::req_method ("GET") |>
httr2::req_retry (
max_tries = 3,
is_transient = \(resp) httr2::resp_status(resp) %in% c(429, 503)
)
resp <- httr2::req_perform (req)
httr2::resp_check_status (resp)
x <- httr2::resp_body_json (resp, simplifyVector = TRUE)

members <- x$members [which (x$members$id %in% editors), ]
if (httr2::resp_is_error (resp)) {

members <- list (
id = NULL,
name = NULL,
real_name = NULL,
status = NULL
)

} else {

x <- httr2::resp_body_json (resp, simplifyVector = TRUE)
members <- x$members [which (x$members$id %in% editors), ]

}

data.frame (
id = members$id,
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "dashboard: What the Package Does (One Line, Title Case)",
"codeRepository": "https://github.com/ropensci-review-tools/dashboard",
"license": "https://spdx.org/licenses/MIT",
"version": "0.2.2.023",
"version": "0.2.2.024",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

1 comment on commit c70e7af

@maelle
Copy link
Contributor

@maelle maelle commented on c70e7af May 14, 2024

Choose a reason for hiding this comment

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

niiice!!

Please sign in to comment.