inst/status.R

# get board columns from GitHub
# descriptions are not available there so we have to add those manually at somem point
projects_custom_accept_header <- "application/vnd.github.inertia-preview+json"
gh_project <- gh::gh("/repos/CorrelAid/projects/projects", .send_headers = c(
  Accept = projects_custom_accept_header
))

columns_url <- gh_project %>% 
  purrr::keep(function(proj) proj$name == "Projects") %>% 
  purrr::map_chr("columns_url")

columns <- gh::gh(columns_url, .send_headers = c(Accept = projects_custom_accept_header))


status <- tibble::tibble(
  status = columns %>% 
    purrr::map_chr("name")
) %>%  
  dplyr::mutate(status = stringr::str_trim(status)) %>% 
  dplyr::mutate(status_id = dplyr::row_number(),
                status_description = "") 

# for manual lookup
status %>% 
  readr::write_csv("inst/status.csv")

# make available as tibble in the package
usethis::use_data(status, internal = FALSE, overwrite = TRUE)
CorrelAid/projectutils documentation built on Oct. 7, 2022, 4:40 a.m.