Skip to content

Commit

Permalink
Remove ability to update covid19tracker dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpaulrsoucy committed Oct 31, 2023
1 parent 04833eb commit af44757
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 75 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export(sync_active_cumul)
export(sync_report)
export(update_active_cumul)
export(update_active_ts)
export(update_covid19tracker)
export(update_covid19tracker_dataset)
export(update_raw_datasets)
export(update_reports)
export(upload_active_cumul)
Expand Down
8 changes: 0 additions & 8 deletions R/update_raw_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,6 @@ update_reports <- function() {
# sync_report("sk_weekly_report", "sk", "hr")
}

#' Update covid19tracker.ca datasets
#' @export
update_covid19tracker <- function() {
cat("Updating covid19tracker.ca datasets...", fill = TRUE)
update_covid19tracker_dataset("hospitalizations")
update_covid19tracker_dataset("icu")
}

#' Update active_cumul datasets
#' @param ds The list of datasets returned by \code{\link[Covid19CanadaETL]{dl_datasets}}.
#' @export
Expand Down
49 changes: 0 additions & 49 deletions R/write_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,55 +59,6 @@ write_ts <- function(d,
)
}

#' Download and write covid19tracker.ca hospitalization or ICU data to "raw_data/covid19tracker" directory
#'
#' @rdname write_funs
#'
#' @export
update_covid19tracker_dataset <- function(val) {
tryCatch(
{
match.arg(val, c("hospitalizations", "icu"))
pt <- get_pt()[["region"]]
if (val == "hospitalizations") {
lapply(pt, function(x) {
# url <- paste0("https://api.covid19tracker.ca/reports/province/", x, "?stat=hospitalizations&fill_dates=false")
url <- paste0("https://api.covid19tracker.ca/reports/province/", x)
jsonlite::fromJSON(url)$data %>%
dplyr::transmute(
name = "hospitalizations",
region = x,
.data$date,
value = .data$total_hospitalizations
)
}) %>%
dplyr::bind_rows() %>%
utils::write.csv("raw_data/covid19tracker/can_hospitalizations_pt_ts.csv", row.names = FALSE)
} else if (val == "icu") {
lapply(pt, function(x) {
# url <- paste0("https://api.covid19tracker.ca/reports/province/", x, "?stat=criticals&fill_dates=false")
url <- paste0("https://api.covid19tracker.ca/reports/province/", x)
jsonlite::fromJSON(url)$data %>%
dplyr::transmute(
name = "icu",
region = x,
.data$date,
value = .data$total_criticals
)
}) %>%
dplyr::bind_rows() %>%
utils::write.csv("raw_data/covid19tracker/can_icu_pt_ts.csv", row.names = FALSE)
} else {
stop("Invalid val.")
}
},
error = function(e) {
print(e)
cat("Error in update_covid19tracker:", val, fill = TRUE)
}
)
}

#' Sync and write report data from Google Sheets
#'
#' @rdname write_funs
Expand Down
11 changes: 0 additions & 11 deletions man/update_covid19tracker.Rd

This file was deleted.

5 changes: 0 additions & 5 deletions man/write_funs.Rd

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

0 comments on commit af44757

Please sign in to comment.