Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add error handlers for the travis issues #17

Merged
merged 7 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/dg_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ dg_call <- function(region_id = NULL,
# ## This is an if statement that handles when we need to get more info on a substat and its parameters
if (!is.null(substat_name)) {

# add_substat_info <- purrr::possibly(add_substat_info, otherwise = NULL)
## TODO: This is necessary because Travis (for some reason) sometimes treats API results as empty
add_substat_info <- purrr::possibly(add_substat_info, otherwise = NULL)

api_results <- add_substat_info(
api_results,
Expand Down
15 changes: 10 additions & 5 deletions R/helpers_call_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ clean_ar <- function(raw) {
purrr::map(~purrr::discard(.x, is.list)) %>%
purrr::set_names(id_dat$id) %>%
purrr::map_dfr(~ .x %>% tibble::as_tibble(), .id = "id") %>%
dplyr::left_join(id_dat, by = "id") %>%
cbind(source_dat) %>%
tibble::as_tibble()
dplyr::left_join(id_dat, by = "id")

## TODO: This is necessary because Travis (for some reason) sometimes thinks source_dat is empty
if (!(nrow(source_dat)==0)) {
final <- final %>%
cbind(source_dat) %>%
tibble::as_tibble()
}


return(final)
Expand Down Expand Up @@ -192,7 +197,7 @@ add_substat_info <- function(api_results,
if (!all_regions) {
suppressMessages(
api_results <- api_results %>%
dplyr::left_join(meta_info)
dplyr::left_join(meta_info, by = substat_name_)
)

if (!is.null(substat_name)) {
Expand All @@ -218,7 +223,7 @@ add_substat_info <- function(api_results,
} else {
suppressMessages(
api_results <- api_results %>%
dplyr::left_join(meta_info) %>%
dplyr::left_join(meta_info, by = substat_name_) %>%
dplyr::select(-substat_name) %>%
dplyr::mutate(year_id = paste0(year, "_", id)) #
)
Expand Down