Skip to content

Commit

Permalink
fix for empty checklists
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterprovoost committed Jun 6, 2019
1 parent ac8d992 commit 98004fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: robis
Title: Ocean Biogeographic Information System (OBIS) Client
Description: Client for the Ocean Biogeographic Information System (<https://obis.org>).
Version: 2.1.8
Date: 2019-06-01
Version: 2.1.9
Date: 2019-06-06
Authors@R: c(
person("Pieter", "Provoost", , "pieterprovoost@gmail.com", c("cre", "aut")),
person("Samuel", "Bosch", , "mail@samuelbosch.com", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# robis 2.1.9

Fix for empty checklists.

# robis 2.1.8

Critical fix for `occurrence()` bug introduced in version 2.1.7.
Expand Down
17 changes: 11 additions & 6 deletions R/checklist.R
Expand Up @@ -39,7 +39,6 @@ checklist <- function(
verbose = FALSE
) {


result_list <- list()
last_page <- FALSE
partition <- 0
Expand Down Expand Up @@ -79,13 +78,19 @@ checklist <- function(
last_page <- TRUE
}

result_list[[partition + 1]] <- res$results
fetched <- fetched + nrow(res$results)
if (is.data.frame(res$results)) {
result_list[[partition + 1]] <- res$results
fetched <- fetched + nrow(res$results)
}
log_progress(fetched, total)

}

data <- bind_rows(result_list)
data <- data[order(data$records, decreasing = TRUE),]
return(data)
if (length(result_list) > 0) {
data <- bind_rows(result_list)
data <- data[order(data$records, decreasing = TRUE),]
return(data)
} else {
return(data.frame())
}
}
8 changes: 6 additions & 2 deletions R/util.R
Expand Up @@ -64,7 +64,11 @@ empty_cols <- function(df) {
}

log_progress <- function(total, count) {
pct <- floor(total / count * 100)
if (pct > 100) pct <- 100
if (count > 0) {
pct <- floor(total / count * 100)
if (pct > 100) pct <- 100
} else {
pct <- 100
}
message(paste0("\rRetrieved ", total, " records of approximately ", count, " (", pct, "%)", sep = ""), appendLF = FALSE)
}

0 comments on commit 98004fb

Please sign in to comment.