From 63694c477a5675254bc503cd158c3f49adc9d187 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 16 Jun 2022 16:15:19 -0700 Subject: [PATCH 1/2] Don't filter by time_value in as_of and removed the min_time_value arg. in as_of and epix_as_of. --- R/archive.R | 7 ++----- R/methods-epi_archive.R | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/R/archive.R b/R/archive.R index f7a98526..7b0f222a 100644 --- a/R/archive.R +++ b/R/archive.R @@ -189,7 +189,7 @@ epi_archive = #' @description Generates a snapshot in `epi_df` format as of a given version. #' See the documentation for the wrapper function `epix_as_of()` for details. #' @importFrom data.table between key - as_of = function(max_version, min_time_value = -Inf) { + as_of = function(max_version) { # Self max version and other keys self_max = max(self$DT$version) other_keys = setdiff(key(self$DT), @@ -213,10 +213,7 @@ epi_archive = # Filter by version and return return( # Make sure to use data.table ways of filtering and selecting - self$DT[between(time_value, - min_time_value, - max_version) & - version <= max_version, ] %>% + self$DT[version <= max_version, ] %>% unique(by = c("geo_value", "time_value", other_keys), fromLast = TRUE) %>% tibble::as_tibble() %>% diff --git a/R/methods-epi_archive.R b/R/methods-epi_archive.R index eb1544f1..ec141f2d 100644 --- a/R/methods-epi_archive.R +++ b/R/methods-epi_archive.R @@ -34,9 +34,9 @@ #' #' # no warning shown #' epix_as_of(archive_cases_dv_subset, max_version = as.Date("2020-06-10")) -epix_as_of = function(x, max_version, min_time_value = -Inf) { +epix_as_of = function(x, max_version) { if (!inherits(x, "epi_archive")) Abort("`x` must be of class `epi_archive`.") - return(x$as_of(max_version, min_time_value)) + return(x$as_of(max_version)) } #' Merge two `epi_archive` objects From 41a6a5c8c467c0092ecc67d53650bbe504e7c4b1 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 27 Jun 2022 22:58:54 -0700 Subject: [PATCH 2/2] Fixed filtering --- R/archive.R | 5 +++-- R/methods-epi_archive.R | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/R/archive.R b/R/archive.R index 7b0f222a..52f41f4f 100644 --- a/R/archive.R +++ b/R/archive.R @@ -189,7 +189,7 @@ epi_archive = #' @description Generates a snapshot in `epi_df` format as of a given version. #' See the documentation for the wrapper function `epix_as_of()` for details. #' @importFrom data.table between key - as_of = function(max_version) { + as_of = function(max_version, min_time_value = -Inf) { # Self max version and other keys self_max = max(self$DT$version) other_keys = setdiff(key(self$DT), @@ -213,7 +213,8 @@ epi_archive = # Filter by version and return return( # Make sure to use data.table ways of filtering and selecting - self$DT[version <= max_version, ] %>% + self$DT[time_value >= min_time_value & + version <= max_version, ] %>% unique(by = c("geo_value", "time_value", other_keys), fromLast = TRUE) %>% tibble::as_tibble() %>% diff --git a/R/methods-epi_archive.R b/R/methods-epi_archive.R index ec141f2d..eb1544f1 100644 --- a/R/methods-epi_archive.R +++ b/R/methods-epi_archive.R @@ -34,9 +34,9 @@ #' #' # no warning shown #' epix_as_of(archive_cases_dv_subset, max_version = as.Date("2020-06-10")) -epix_as_of = function(x, max_version) { +epix_as_of = function(x, max_version, min_time_value = -Inf) { if (!inherits(x, "epi_archive")) Abort("`x` must be of class `epi_archive`.") - return(x$as_of(max_version)) + return(x$as_of(max_version, min_time_value)) } #' Merge two `epi_archive` objects