Skip to content

Commit 8679add

Browse files
authored
Merge pull request #69 from Boehringer-Ingelheim/342810-expand_review_revision_limit
[review] Expand revision count limit from 1000 to 10000 entries
2 parents 3e43695 + 24676af commit 8679add

5 files changed

Lines changed: 30 additions & 11 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: dv.listings
22
Type: Package
33
Title: Data listings module
4-
Version: 4.3.4-9003
4+
Version: 4.3.4-9004
55
Authors@R:
66
c(
77
person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# dv.listings 4.3.4-9004
2+
- Review functionality:
3+
- Expand revision count limit from 1000 to 10000 entries
4+
15
# dv.listings 4.3.4-9003
26
- Review functionality:
37
- Guard against problematic characters in dataset names

R/review.R

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,21 @@ REV_load_annotation_info <- function(folder_contents, review, dataset_lists) {
259259

260260
base_timestamp <- NA_real_
261261
data_timestamps_st <- rep(NA_real_, row_count)
262-
# <domain>_000.base
263-
file_path <- file.path(dataset_lists_name, paste0(dataset_review_name, "_000.base"))
264-
if (file_path %in% names(folder_contents)) {
265-
contents <- folder_contents[[file_path]]
262+
263+
# <domain>_0000.base
264+
# - Older versions of the review functionality devoted three digits to the `.base` and `.delta` sequence numbers.
265+
# The current version uses four digits. Here we detect the one that was used for this particular domain (if it
266+
# exists) and use it for the associated delta files.
267+
base_file_path_pattern <- sprintf("^%s_0+.base$", file.path(dataset_lists_name, dataset_review_name))
268+
base_file_path <- grep(base_file_path_pattern, names(folder_contents), value = TRUE)
269+
if (length(base_file_path) > 1L) {
270+
error <- c(error, paste0("[", dataset_review_name, "] ", "Multiple `.base` files found:\n",
271+
paste(sprintf("`%s`", base_file_path), collapse = ", "), ".\n"))
272+
base_file_path <- sort(base_file_path)[[1]]
273+
}
274+
275+
if (length(base_file_path) == 1) { # existing `.base` file
276+
contents <- folder_contents[[base_file_path]]
266277

267278
sorted_delta_file_paths <- local({
268279
pattern <- sprintf("^%s_[0-9]*.delta", file.path(dataset_lists_name, dataset_review_name))
@@ -383,18 +394,22 @@ REV_load_annotation_info <- function(folder_contents, review, dataset_lists) {
383394
base_info <- RS_load(contents, deltas)
384395

385396
delta_number <- length(sorted_delta_file_paths) + 1
386-
file_path <- file.path(dataset_lists_name, sprintf("%s_%03d.delta", dataset_review_name, delta_number))
397+
revision_digit_count <- nchar(sub(".*_(0+)\\.base$", "\\1", base_file_path))
398+
file_path <- file.path(
399+
dataset_lists_name, sprintf("%s_%.*d.delta", dataset_review_name, revision_digit_count, delta_number)
400+
)
387401
append_IO_action(list(kind = "write", path = file_path, contents = new_delta_contents, offset = 0L))
388402
}
389403
}
390-
} else {
404+
} else { # new `.base` file
405+
base_file_path <- file.path(dataset_lists_name, paste0(dataset_review_name, "_0000.base"))
391406
contents <- RS_compute_base_memory(dataset_review_name, dataset, id_vars, tracked_vars)
392407
if (inherits(contents, "simpleCondition")) {
393408
# IMPORTANT: Not being able to compute the base info is too severe an error to recover from, so we error out
394409
return(list(error = c(error, contents[["message"]])))
395410
} else {
396411
base_info <- RS_load(base = contents, deltas = list())
397-
append_IO_action(list(kind = "write", path = file_path, contents = contents, offset = 0L))
412+
append_IO_action(list(kind = "write", path = base_file_path, contents = contents, offset = 0L))
398413
}
399414
}
400415

tests/testthat/test-review.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ local({
4444
expect_length(info[["IO_plan"]], 1)
4545
folder_op <- info[["IO_plan"]][[1]]
4646
expect_equal(folder_op[["kind"]], "write")
47-
expect_equal(folder_op[["path"]], "dataset_list/ae_001.delta")
47+
expect_equal(folder_op[["path"]], "dataset_list/ae_0001.delta")
4848
expect_equal(folder_op[["offset"]], 0L)
4949

5050
delta <- RS_parse_delta(info[["IO_plan"]][[1]][["contents"]], length(tracked_vars))

vignettes/data_review.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Lastly, using plain file storage allows for easy local testing and for universal
157157

158158
If we take a hypothetical "xyz" domain, `dv.listings` will store the following files for review purposes (expand to see the layout of their contents):
159159

160-
<details><summary>`xyz_000.base` (information related to the first version of the "xyz" domain dataset seen by the module)</summary>
160+
<details><summary>`xyz_0000.base` (information related to the first version of the "xyz" domain dataset seen by the module)</summary>
161161
- 1 file magic code ("LISTBASE")
162162
- 1 format version number (0)
163163
- 1 generation marker (0)
@@ -173,7 +173,7 @@ If we take a hypothetical "xyz" domain, `dv.listings` will store the following f
173173
- p (1 per "xyz" row, 2\*m bytes long) `hash_tracked(xyz[tracked_vars])`
174174
</details>
175175

176-
<details><summary>`xyz_001.delta` (one per domain dataset update)</summary>
176+
<details><summary>`xyz_0001.delta` (one per domain dataset update)</summary>
177177
- 1 file magic code ("LISTDELT")
178178
- 1 format version number (0)
179179
- 1 generation marker (1). Wraps around to 0 after 255 (e.g. for `xyz_256.delta`)

0 commit comments

Comments
 (0)