feat: работа с несколькими схемами в пределах одного приложения

This commit is contained in:
2026-04-13 12:43:47 +03:00
parent dbfe27bbb8
commit 1b7220e647
6 changed files with 177 additions and 116 deletions

View File

@@ -125,18 +125,28 @@ scheme_R6 <- R6::R6Class(
c("subgroup", "form_id", "form_label", "form_type")
)
readxl::read_xlsx(private$scheme_file_path, sheet = sheet_name) |>
table <- readxl::read_xlsx(private$scheme_file_path, sheet = sheet_name) |>
# fill NA down
tidyr::fill(all_of(colnames), .direction = "down") |>
dplyr::group_by(form_id) |>
tidyr::fill(c(condition, required), .direction = "down") |>
dplyr::ungroup()
duplicate_ids <- table |>
dplyr::mutate(rleid = dplyr::consecutive_id(form_id)) |>
dplyr::distinct(form_id, rleid) |>
dplyr::count(form_id) |>
dplyr::filter(n > 1) |>
dplyr::pull(form_id)
if (length(duplicate_ids) > 0) {
cli::cli_abort(c("В схеме для формы '{sheet_name}' содержатся повторяющиеся id:", paste("-", duplicate_ids)))
}
table
}
)
)
# schm <- scheme_R6$new(fs::path("configs/schemas", "schema.xlsx"))
# object.size(schm)
# schm$get_key_id("main")
# schm$get_forms_ids("main")