Created
January 22, 2019 21:17
-
-
Save yutannihilation/9770dbbc0710e4731e8925bed0c85fd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get the URLs of locked pull requests ------------------------------------ | |
# c.f. | |
p <- gh::gh("GET /repos/tidyverse/ggplot2/pulls", | |
state = "closed", | |
since = "2019-01-17T00:00:00Z", .limit = Inf) | |
p_locked <- purrr::keep(p, "locked") | |
p_locked_url <- purrr::map_chr(p_locked, "url") | |
# get notifications ------------------------------------------------------- | |
# .c.f. https://developer.github.com/v3/activity/notifications/#list-your-notifications | |
n <- gh::gh("GET /notifications", | |
since = "2019-01-17T00:00:00Z", .limit = Inf) | |
idx <- purrr::map_chr(n, c("subject", "url")) %in% p_locked_url | |
n_locked <- n[idx] | |
n_locked_url <- purrr::map_chr(n_locked, "url") | |
# mark the locked notifications as read ----------------------------------- | |
# c.f. https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read | |
mark_as_read <- function(e) { | |
# https://developer.github.com/v3/guides/best-practices-for-integrators/#dealing-with-abuse-rate-limits: | |
# "If you're making a large number of POST, PATCH, PUT, or DELETE requests | |
# for a single user or client ID, wait at least one second between each request." | |
Sys.sleep(1) | |
message(e) | |
gh::gh(e) | |
} | |
result <- purrr::map(paste("PATCH", n_locked_url), mark_as_read) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment