From 5b41330e01cf9510dbff4df9ae72a7e2577e553a Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sat, 20 Jul 2024 15:19:02 +0800 Subject: [PATCH 01/11] Increment version number to 3.12.0.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 59c8218..a9a1b40 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tarflow.iquizoo Title: Setup "targets" Workflows for "iquizoo" Data Processing -Version: 3.12.0 +Version: 3.12.0.9000 Authors@R: c( person("Liang", "Zhang", , "psychelzh@outlook.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9041-1150")), diff --git a/NEWS.md b/NEWS.md index 403e18c..2432acb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# tarflow.iquizoo (development version) + # tarflow.iquizoo 3.12.0 ## New Features From 88a2165ccd5644acbb69f9abd2cae0e1db6b9ff4 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sat, 20 Jul 2024 19:09:15 +0800 Subject: [PATCH 02/11] Increment version number to 3.12.1.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa96607..972bd35 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tarflow.iquizoo Title: Setup "targets" Workflows for "iquizoo" Data Processing -Version: 3.12.1 +Version: 3.12.1.9000 Authors@R: c( person("Liang", "Zhang", , "psychelzh@outlook.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9041-1150")), diff --git a/NEWS.md b/NEWS.md index 508f71d..10611a9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# tarflow.iquizoo (development version) + # tarflow.iquizoo 3.12.1 ## Enhancements From 3c918f0c86fc622cc6cd3eefe9b75a5b500571b2 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 21 Jul 2024 09:18:21 +0800 Subject: [PATCH 03/11] Simplify sql query Signed-off-by: Liang Zhang --- inst/sql/progress_hash.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/sql/progress_hash.sql b/inst/sql/progress_hash.sql index 1b66092..4831c53 100644 --- a/inst/sql/progress_hash.sql +++ b/inst/sql/progress_hash.sql @@ -1,6 +1,6 @@ SELECT - MD5(concat_ws(", ", pcc.Id, FinishedUserCount, ConfiguredUserCount, Progress, CompletionRate)) AS MD5 + MD5(concat_ws(", ", Id, FinishedUserCount, ConfiguredUserCount, Progress, CompletionRate)) AS MD5 FROM - iquizoo_business_db.project_course_config pcc + iquizoo_business_db.project_course_config WHERE - pcc.Id = ?; + Id = ?; From 83da237455dd94ff20f9d6e18dc1cc2ed30d2ca3 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 21 Jul 2024 09:21:27 +0800 Subject: [PATCH 04/11] Ensure organization is not deleted Signed-off-by: Liang Zhang --- inst/sql/users.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/sql/users.sql b/inst/sql/users.sql index efcc161..f34da3f 100644 --- a/inst/sql/users.sql +++ b/inst/sql/users.sql @@ -12,5 +12,6 @@ FROM AND organization_user.Deleted <> 1 INNER JOIN iquizoo_user_db.base_organization ON base_organization.Id = organization_user.OrganizationId + AND base_organization.Deleted <> 1 WHERE project_course_config.Id = ?; From 38c2967a4d10152f1b16f87312676e1bc04b8a06 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 21 Jul 2024 09:35:41 +0800 Subject: [PATCH 05/11] Let disk cache expire in 7 days Signed-off-by: Liang Zhang --- R/database.R | 12 ++++++++---- man/fetch_iquizoo_mem.Rd | 7 ++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/R/database.R b/R/database.R index 9a38340..4ddb718 100644 --- a/R/database.R +++ b/R/database.R @@ -49,9 +49,10 @@ fetch_iquizoo <- function(query, ..., #' @param cache The cache to be used. Default cache could be configured by #' setting the environment variable `TARFLOW_CACHE` to `"disk"` or `"memory"`. #' If set `TARFLOW_CACHE` to `"disk"`, the cache will be stored in disk at -#' `~/.cache/tarflow.iquizoo`. If set `TARFLOW_CACHE` to `"memory"`, the cache -#' will be stored in memory. You can also set `cache` to a custom cache, see -#' [memoise::memoise()] for more details. +#' `~/.cache/tarflow.iquizoo` with a maximal age of 7 days. If set +#' `TARFLOW_CACHE` to `"memory"`, the cache will be stored in memory. You can +#' also set `cache` to a custom cache, see [memoise::memoise()] for more +#' details. #' @return A memoised version of [fetch_iquizoo()]. #' @seealso [fetch_iquizoo()] for the original function. #' @export @@ -59,7 +60,10 @@ fetch_iquizoo_mem <- function(cache = NULL) { requireNamespace("digest", quietly = TRUE) if (is.null(cache)) { cache <- switch(Sys.getenv("TARFLOW_CACHE", "disk"), - disk = cachem::cache_disk("~/.cache/tarflow.iquizoo"), + disk = cachem::cache_disk( + "~/.cache/tarflow.iquizoo", + max_age = 3600 * 24 * 7 # 7 days + ), memory = cachem::cache_mem() ) } diff --git a/man/fetch_iquizoo_mem.Rd b/man/fetch_iquizoo_mem.Rd index c4ac02f..9438f12 100644 --- a/man/fetch_iquizoo_mem.Rd +++ b/man/fetch_iquizoo_mem.Rd @@ -10,9 +10,10 @@ fetch_iquizoo_mem(cache = NULL) \item{cache}{The cache to be used. Default cache could be configured by setting the environment variable \code{TARFLOW_CACHE} to \code{"disk"} or \code{"memory"}. If set \code{TARFLOW_CACHE} to \code{"disk"}, the cache will be stored in disk at -\verb{~/.cache/tarflow.iquizoo}. If set \code{TARFLOW_CACHE} to \code{"memory"}, the cache -will be stored in memory. You can also set \code{cache} to a custom cache, see -\code{\link[memoise:memoise]{memoise::memoise()}} for more details.} +\verb{~/.cache/tarflow.iquizoo} with a maximal age of 7 days. If set +\code{TARFLOW_CACHE} to \code{"memory"}, the cache will be stored in memory. You can +also set \code{cache} to a custom cache, see \code{\link[memoise:memoise]{memoise::memoise()}} for more +details.} } \value{ A memoised version of \code{\link[=fetch_iquizoo]{fetch_iquizoo()}}. From 53dc123ff18375c1383b6cab77657f570db37076 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 21 Jul 2024 09:41:51 +0800 Subject: [PATCH 06/11] NEWS bulletin Signed-off-by: Liang Zhang --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 10611a9..2ab8034 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # tarflow.iquizoo (development version) +## Enhancements + +* Added a default expiration time for disk cache in `fetch_iquizoo_mem()` of 7 days. + # tarflow.iquizoo 3.12.1 ## Enhancements From ae6c8e6253f920b6b3c3ca286108023babbbb126 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 22 Jul 2024 14:15:53 +0800 Subject: [PATCH 07/11] Move data.iquizoo to Suggests Signed-off-by: Liang Zhang --- DESCRIPTION | 8 ++++---- R/targets.R | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 972bd35..e926cd0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,6 @@ Depends: Imports: cachem, cli, - data.iquizoo (>= 2024.3.31.2), DBI, glue, jsonlite, @@ -31,6 +30,7 @@ Imports: Suggests: bit64, covr, + data.iquizoo (>= 2024.7.14), digest, lifecycle, odbc, @@ -41,9 +41,9 @@ Suggests: testthat (>= 3.0.0), tibble, withr -Remotes: - psychelzh/data.iquizoo, - psychelzh/preproc.iquizoo +Remotes: + psychelzh/preproc.iquizoo, + psychelzh/data.iquizoo Config/testthat/edition: 3 Config/testthat/parallel: true Config/testthat/start-first: targets diff --git a/R/targets.R b/R/targets.R index 44696e7..645f542 100644 --- a/R/targets.R +++ b/R/targets.R @@ -296,7 +296,10 @@ tar_prep_raw <- function(contents, ) }, indices = if ("preproc" %in% action_raw_data) { - check_installed("preproc.iquizoo", "becasue required in pre-processing.") + check_installed( + c("preproc.iquizoo", "data.iquizoo"), + "becasue required in pre-processing." + ) tarchetypes::tar_eval( targets::tar_target( tar_indices, From b36244c69e8407e4ec7bb526753d0b8cf324fb6a Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 22 Jul 2024 14:18:45 +0800 Subject: [PATCH 08/11] NEWS bulletin Signed-off-by: Liang Zhang --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 2ab8034..9a13d12 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,10 @@ * Added a default expiration time for disk cache in `fetch_iquizoo_mem()` of 7 days. +## Misc + +* Moved data.iquizoo to Suggests. The logic behind is the same as that of preproc.iquizoo. + # tarflow.iquizoo 3.12.1 ## Enhancements From c165aacdde8720b1506569016e80f0e7bba4b37e Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 22 Jul 2024 14:32:57 +0800 Subject: [PATCH 09/11] Remove two more Suggests packages Signed-off-by: Liang Zhang --- DESCRIPTION | 6 ++---- R/targets.R | 7 +------ tests/testthat/helper-expections.R | 10 ++++++---- tests/testthat/test_basic-cases.R | 3 +-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e926cd0..1c1d555 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,13 +35,11 @@ Suggests: lifecycle, odbc, preproc.iquizoo (>= 2.6.0), - purrr, RMariaDB (>= 1.3.1), roxygen2, testthat (>= 3.0.0), - tibble, - withr -Remotes: + tibble +Remotes: psychelzh/preproc.iquizoo, psychelzh/data.iquizoo Config/testthat/edition: 3 diff --git a/R/targets.R b/R/targets.R index 645f542..41a9625 100644 --- a/R/targets.R +++ b/R/targets.R @@ -107,12 +107,7 @@ tar_prep_iquizoo <- function(params, contents, ..., targets, lapply( intersect(combine, names(targets)), - \(name) { - tarchetypes::tar_combine_raw( - name, - targets[[name]] - ) - } + \(name) tarchetypes::tar_combine_raw(name, targets[[name]]) ) ) } diff --git a/tests/testthat/helper-expections.R b/tests/testthat/helper-expections.R index adbe9b5..5f87fdc 100644 --- a/tests/testthat/helper-expections.R +++ b/tests/testthat/helper-expections.R @@ -5,10 +5,12 @@ expect_targets_list <- function(targets) { sprintf("%s should be a list, not a %s.", act$lab, typeof(act$val)) ) } - if (!all(purrr::map_lgl(unlist(act$val), \(x) inherits(x, "tar_target")))) { - testthat::fail( - sprintf("All elements of %s should be valid target objects.", act$lab) - ) + for (val in unlist(act$val)) { + if (!inherits(val, "tar_target")) { + testthat::fail( + sprintf("All elements of %s should be valid target objects.", act$lab) + ) + } } testthat::succeed() invisible(act$val) diff --git a/tests/testthat/test_basic-cases.R b/tests/testthat/test_basic-cases.R index 0e98f55..d5433cb 100644 --- a/tests/testthat/test_basic-cases.R +++ b/tests/testthat/test_basic-cases.R @@ -41,13 +41,12 @@ targets::tar_test("`combine` work properly", { }) targets::tar_test("Serialize check (no roundtrip error)", { - withr::local_envvar(c(TARFLOW_CACHE = "memory")) targets::tar_script({ params <- tibble::tribble( ~organization_name, ~project_name, ~course_name, ~game_name, "四川省双流棠湖中学高中部", "棠湖中学英才计划测训体验账号", NA, NA ) - tar_prep_iquizoo(params)[1] + tar_prep_iquizoo(params, cache = cachem::cache_mem())[1] }) targets::tar_make(reporter = "silent", callr_function = NULL) expect_identical( From 7a38c646ae444a67323b64b53877eeaf63827bfd Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 22 Jul 2024 14:34:01 +0800 Subject: [PATCH 10/11] Increment version number to 3.12.2 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1c1d555..0064344 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tarflow.iquizoo Title: Setup "targets" Workflows for "iquizoo" Data Processing -Version: 3.12.1.9000 +Version: 3.12.2 Authors@R: c( person("Liang", "Zhang", , "psychelzh@outlook.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9041-1150")), diff --git a/NEWS.md b/NEWS.md index 9a13d12..b51eeda 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# tarflow.iquizoo (development version) +# tarflow.iquizoo 3.12.2 ## Enhancements From a16c88659bf309ec0e78238f7ee8dfbbccb5e003 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 22 Jul 2024 14:37:13 +0800 Subject: [PATCH 11/11] Tidy description Signed-off-by: Liang Zhang --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0064344..609f6ed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,8 +40,8 @@ Suggests: testthat (>= 3.0.0), tibble Remotes: - psychelzh/preproc.iquizoo, - psychelzh/data.iquizoo + psychelzh/data.iquizoo, + psychelzh/preproc.iquizoo Config/testthat/edition: 3 Config/testthat/parallel: true Config/testthat/start-first: targets