Skip to content

Commit

Permalink
Fix another bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhsparks committed Oct 29, 2024
1 parent cd7e3f6 commit 95746da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/get_smips.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ get_smips <- function(collection = "totalbucket",
url_date <- gsub("-", "", day)
url_year <- lubridate::year(day)

.check_collection_agreement(.collection = collection, .url_date = url_date)
.check_collection_agreement(.collection = collection, .day = day)

approved_collections <- c("totalbucket",
"SMindex",
Expand Down Expand Up @@ -67,14 +67,14 @@ get_smips <- function(collection = "totalbucket",
return(r)
}

.check_collection_agreement <- function(.collection, .url_date) {
.check_collection_agreement <- function(.collection, .day) {
.this_year <- lubridate::year(lubridate::today())
.last_week <- lubridate::today() - 7
.url_year <- lubridate::year(.url_date)
.url_year <- lubridate::year(.day)

if (.collection == "totalbucket" &&
.url_year < 2005 ||
.url_date > .last_week) {
.day > .last_week) {
cli::cli_abort("The data are not available before 2005 and past {.last_week}")
}
}

0 comments on commit 95746da

Please sign in to comment.