From af4475736cfcda4772ebb654cd6309c93f7c4198 Mon Sep 17 00:00:00 2001 From: "Jean-Paul R. Soucy" Date: Tue, 31 Oct 2023 14:59:37 -0400 Subject: [PATCH] Remove ability to update covid19tracker dataset --- NAMESPACE | 2 -- R/update_raw_datasets.R | 8 ------ R/write_funs.R | 49 ------------------------------------ man/update_covid19tracker.Rd | 11 -------- man/write_funs.Rd | 5 ---- 5 files changed, 75 deletions(-) delete mode 100644 man/update_covid19tracker.Rd diff --git a/NAMESPACE b/NAMESPACE index 223c2d9..1bc96aa 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/update_raw_datasets.R b/R/update_raw_datasets.R index bc4a368..5b47448 100644 --- a/R/update_raw_datasets.R +++ b/R/update_raw_datasets.R @@ -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 diff --git a/R/write_funs.R b/R/write_funs.R index 72bd9c0..b0a5ad4 100644 --- a/R/write_funs.R +++ b/R/write_funs.R @@ -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 diff --git a/man/update_covid19tracker.Rd b/man/update_covid19tracker.Rd deleted file mode 100644 index 582b2e4..0000000 --- a/man/update_covid19tracker.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/update_raw_datasets.R -\name{update_covid19tracker} -\alias{update_covid19tracker} -\title{Update covid19tracker.ca datasets} -\usage{ -update_covid19tracker() -} -\description{ -Update covid19tracker.ca datasets -} diff --git a/man/write_funs.Rd b/man/write_funs.Rd index a94b431..42612ba 100644 --- a/man/write_funs.Rd +++ b/man/write_funs.Rd @@ -3,7 +3,6 @@ \name{write_funs} \alias{write_funs} \alias{write_ts} -\alias{update_covid19tracker_dataset} \alias{sync_report} \alias{sync_active_cumul} \alias{write_dataset} @@ -11,8 +10,6 @@ \usage{ write_ts(d, dir = c("active_ts", "active_cumul"), region, val) -update_covid19tracker_dataset(val) - sync_report(sheet, region, geo) sync_active_cumul(sheet, val, regions, as_of_date = FALSE) @@ -46,8 +43,6 @@ Functions to write data Write processed data to a specific directory in "raw_data" -Download and write covid19tracker.ca hospitalization or ICU data to "raw_data/covid19tracker" directory - Sync and write report data from Google Sheets Sync and write active_cumul data from Google Sheets