Skip to content

Commit f9ebd45

Browse files
committed
format progress bars
1 parent 781aa0a commit f9ebd45

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

R/load_tree_data.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ load_tree_data <- function(src, table = NULL, columns = DEFAULT_TREE_COLUMNS,
224224
if (is.null(sql) && !is.null(columns) && columns[1] != "")
225225
ds$setSelectedFields(columns)
226226

227-
cli::cli_progress_step("Fetching tree data...")
227+
cli::cli_progress_step("Fetching tree data...",
228+
msg_done = "Fetching tree data.")
228229
d <- ds$fetch(-1)
229230
cli::cli_progress_done()
230231

R/process_tree_data.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ process_tree_data <- function(tree_table, stem_map = TRUE, full_output = TRUE,
8989
tree_list <- tree_table[tree_table$PLT_CN == plot_ids[1], ]
9090
x <- calc_tcc_metrics(tree_list, stem_map, full_output, digits, window = w)
9191

92+
cli::cli_alert_info(
93+
"The input table contains tree data for {.val {num_plots}} plots.")
94+
9295
out <- vector("list", 1 + length(x))
9396
names(out) <- c("PLT_CN", names(x))
9497

@@ -109,10 +112,14 @@ process_tree_data <- function(tree_table, stem_map = TRUE, full_output = TRUE,
109112
out[[j]] <- rep_len(NA_real_, num_plots)
110113
}
111114

112-
cli::cli_alert_info(
113-
"The input table contains tree data for {.val {num_plots}} plots.")
115+
cli::cli_progress_bar(
116+
"Processing...",
117+
format_done = paste0(
118+
"{cli::col_green(cli::symbol$tick)} Processed ",
119+
"{.val {cli::pb_total}} plots in {cli::pb_elapsed}."),
120+
total = num_plots,
121+
clear = FALSE)
114122

115-
cli::cli_progress_bar("Processing...", total = num_plots)
116123
for (i in seq_along(plot_ids)) {
117124
tree_list <- tree_table[tree_table$PLT_CN == plot_ids[i], ]
118125
x <- calc_tcc_metrics(tree_list, stem_map, full_output, digits,
@@ -124,7 +131,6 @@ process_tree_data <- function(tree_table, stem_map = TRUE, full_output = TRUE,
124131
cli::cli_progress_update()
125132
}
126133
cli::cli_progress_done()
127-
cli::cli_alert_info("Done.")
128134

129135
as.data.frame(out)
130136
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ f <- system.file("extdata/mt_lnf_2022_1cond_tree.csv", package="FIAstemmap")
300300
tree_table <- load_tree_data(f)
301301
#> ! the data source does not have DIST and/or AZIMUTH
302302
#> ℹ Fetching tree data...
303-
#> ✔ Fetching tree data... [14ms]
303+
#> ✔ Fetching tree data. [14ms]
304304
#>
305305
#> ℹ 910 tree records returned.
306306

@@ -315,7 +315,6 @@ head(tree_table)
315315

316316
process_tree_data(tree_table, stem_map = FALSE, full_output = TRUE)
317317
#> ℹ The input table contains tree data for 22 plots.
318-
#> ℹ Done.
319318
#> PLT_CN model_tcc numTrees meanTreeHt meanTreeHtBAW meanTreeHtDom
320319
#> 1 670951075126144 1.2 0 0.0 0.0 0.0
321320
#> 2 670950940126144 38.4 24 61.4 66.4 64.5

0 commit comments

Comments
 (0)