Skip to content

Commit

Permalink
removed additional line break from code. (#989)
Browse files Browse the repository at this point in the history
this fixes
insightsengineering/teal.gallery#113

---------

Signed-off-by: kartikeya kirar <[email protected]>
Co-authored-by: Aleksander Chlebowski <[email protected]>
  • Loading branch information
kartikeyakirar and chlebowa authored Dec 1, 2023
1 parent 3d7692f commit e95ba8f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
43 changes: 21 additions & 22 deletions R/get_rcode_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,38 @@ get_rcode_str_install <- function() {
#' @param datasets (`FilteredData`) object
#' @param hashes named (`list`) of hashes per dataset
#'
#' @return `character(3)` containing the following elements:
#' @return Character string concatenated from the following elements:
#' - data pre-processing code (from `data` argument in `init`)
#' - hash check of loaded objects
#' - filter code
#' - filter code (if any)
#'
#' @keywords internal
get_datasets_code <- function(datanames, datasets, hashes) {
# preprocessing code
str_prepro <- teal.data:::get_code_dependency(attr(datasets, "preprocessing_code"), names = datanames)
if (length(str_prepro) == 0) {
str_prepro <- "message('Preprocessing is empty')"
} else if (length(str_prepro) > 0) {
str_prepro <- paste0(str_prepro, "\n\n")
} else {
str_prepro <- paste(str_prepro, collapse = "\n")
}

str_hash <- paste(
paste0(
vapply(
datanames,
function(dataname) {
sprintf(
"stopifnot(%s == %s)",
deparse1(bquote(rlang::hash(.(as.name(dataname))))),
deparse1(hashes[[dataname]])
)
},
character(1)
),
collapse = "\n"
),
"\n\n"
)
# hash checks
str_hash <- vapply(datanames, function(dataname) {
sprintf(
"stopifnot(%s == %s)",
deparse1(bquote(rlang::hash(.(as.name(dataname))))),
deparse1(hashes[[dataname]])
)
}, character(1))
str_hash <- paste(str_hash, collapse = "\n")

# filter expressions
str_filter <- teal.slice::get_filter_expr(datasets, datanames)
if (str_filter == "") {
str_filter <- character(0)
}

c(str_prepro, str_hash, str_filter)
# concatenate all code
str_code <- paste(c(str_prepro, str_hash, str_filter), collapse = "\n\n")
sprintf("%s\n", str_code)
}
3 changes: 1 addition & 2 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi
code <- c(
get_rcode_str_install(),
get_rcode_libraries(),
get_datasets_code(datanames, datasets, hashes),
teal.slice::get_filter_expr(datasets, datanames)
get_datasets_code(datanames, datasets, hashes)
)

do.call(
Expand Down
4 changes: 2 additions & 2 deletions man/get_datasets_code.Rd

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

0 comments on commit e95ba8f

Please sign in to comment.