Skip to content

Commit

Permalink
Better peeking if there are no pages to download
Browse files Browse the repository at this point in the history
  • Loading branch information
clente committed May 28, 2018
1 parent c0c6ac4 commit 2e14098
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
20 changes: 13 additions & 7 deletions R/cjpg.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,20 @@ peek_cjpg <- function(...) {
as.numeric() %>%
magrittr::divide_by(.[1]) %>%
purrr::pluck(2) %>%
`%||%`(0) %>%
ceiling()

# Print message
min_p <- ifelse(min_p == -1, 1, min_p)
max_p <- ifelse(max_p == -1, pages, max_p)
message(
"There are ", (max_p - min_p + 1), " pages to download\n",
"This should take around ",
how_long((max_p - min_p + 1) * 0.5105))
invisible(pages)
if (pages == 0) {
message("There are no pages to download")
invisible(pages)
}
else {
min_p <- ifelse(min_pag == -1, 1, min_pag)
message(
"There are ", (pages - min_pag + 1), " pages to download\n",
"This should take around ",
how_long((pages - min_p + 1) * 0.5105))
invisible(pages)
}
}
20 changes: 14 additions & 6 deletions R/cjsg.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,25 @@ cjsg_npags <- function(path) {
as.numeric() %>%
magrittr::divide_by(.[1]) %>%
purrr::pluck(2) %>%
`%||%`(0) %>%
ceiling()
}

cjsg_print_npags <- function(pages, min_pag) {

# Print message
min_p <- ifelse(min_pag == -1, 1, min_pag)
message(
"There are ", (pages - min_pag + 1), " pages to download\n",
"This should take around ",
how_long((pages - min_p + 1) * 0.5105))
invisible(pages)
if (pages == 0) {
message("There are no pages to download")
invisible(pages)
}
else {
min_p <- ifelse(min_pag == -1, 1, min_pag)
message(
"There are ", (pages - min_pag + 1), " pages to download\n",
"This should take around ",
how_long((pages - min_p + 1) * 0.5105))
invisible(pages)
}
}

#' Check how long a call to [download_cjsg()] will probably take
Expand Down

0 comments on commit 2e14098

Please sign in to comment.