Skip to content

Commit

Permalink
Add rudimentary progress bar fix #141 (#143)
Browse files Browse the repository at this point in the history
* Add rudimentary progress bar

* Make progress bar only show when pages > 1

and resolve my OCD
  • Loading branch information
chainsawriot authored Nov 10, 2023
1 parent 519937a commit d9486dc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ process_request <- function(token = NULL,
}
pages <- ceiling(n/page_size)
output <- vector("list")
if (verbose && pages > 1) {
pb <- txtProgressBar(min = 1, max = pages, style = 3)
show_progress <- TRUE
} else {
show_progress <- FALSE
}
for(i in seq_len(pages)){
api_response <- make_get_request(token = token,path = path,
instance = instance, params = params,
Expand All @@ -131,13 +137,19 @@ process_request <- function(token = NULL,
break
}
params[[pager]] <- attr(api_response, "headers")[[pager]]
if (verbose && show_progress) {
setTxtProgressBar(pb, i)
}
}
if (isTRUE(parse)) {
header <- attr(output, "headers")

output <- FUN(output)
attr(output, "headers") <- header
}
if (show_progress) {
cat("\n")
}
return(output)
}

Expand Down

0 comments on commit d9486dc

Please sign in to comment.