Skip to content

Commit

Permalink
Merge branch 'release/3.12.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
psychelzh committed Jul 22, 2024
2 parents fb99e4d + a16c886 commit 2b15843
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 28 deletions.
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tarflow.iquizoo
Title: Setup "targets" Workflows for "iquizoo" Data Processing
Version: 3.12.1
Version: 3.12.2
Authors@R: c(
person("Liang", "Zhang", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9041-1150")),
Expand All @@ -20,7 +20,6 @@ Depends:
Imports:
cachem,
cli,
data.iquizoo (>= 2024.3.31.2),
DBI,
glue,
jsonlite,
Expand All @@ -31,16 +30,15 @@ Imports:
Suggests:
bit64,
covr,
data.iquizoo (>= 2024.7.14),
digest,
lifecycle,
odbc,
preproc.iquizoo (>= 2.6.0),
purrr,
RMariaDB (>= 1.3.1),
roxygen2,
testthat (>= 3.0.0),
tibble,
withr
tibble
Remotes:
psychelzh/data.iquizoo,
psychelzh/preproc.iquizoo
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# tarflow.iquizoo 3.12.2

## Enhancements

* 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
Expand Down
12 changes: 8 additions & 4 deletions R/database.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ 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
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()
)
}
Expand Down
12 changes: 5 additions & 7 deletions R/targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
)
)
}
Expand Down Expand Up @@ -296,7 +291,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,
Expand Down
6 changes: 3 additions & 3 deletions inst/sql/progress_hash.sql
Original file line number Diff line number Diff line change
@@ -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 = ?;
1 change: 1 addition & 0 deletions inst/sql/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ?;
7 changes: 4 additions & 3 deletions man/fetch_iquizoo_mem.Rd

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

10 changes: 6 additions & 4 deletions tests/testthat/helper-expections.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test_basic-cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2b15843

Please sign in to comment.