From 006610dd4d08fdefd27641445b7275b82723eeca Mon Sep 17 00:00:00 2001 From: David Dorchies <14124454+DDorch@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:07:42 +0100 Subject: [PATCH] fix(get_hydrometrie_observations_tr): crashes when returns empty result Closes #47 --- DESCRIPTION | 2 +- R/get_hydrometrie.R | 5 ++--- tests/testthat/test-run_all_examples.R | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 17fd75e..bc2e1e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,4 +48,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/R/get_hydrometrie.R b/R/get_hydrometrie.R index f48c774..4965b94 100644 --- a/R/get_hydrometrie.R +++ b/R/get_hydrometrie.R @@ -64,7 +64,7 @@ get_hydrometrie_observations_tr <- function(..., endpoint = "observations_tr", ... ) - if(!is.null(l)) { + if (length(l) > 0) { l <- lapply(l, function(x) { if (entities == "station") { if (is.null(x$code_station)) { @@ -78,9 +78,8 @@ get_hydrometrie_observations_tr <- function(..., return(x) }) l[sapply(l, is.null)] <- NULL - l <- convert_list_to_tibble(l) } - return(l) + return(convert_list_to_tibble(l)) } diff --git a/tests/testthat/test-run_all_examples.R b/tests/testthat/test-run_all_examples.R index afb0d91..3f70375 100644 --- a/tests/testthat/test-run_all_examples.R +++ b/tests/testthat/test-run_all_examples.R @@ -25,5 +25,3 @@ lapply(db, function(Rd_fun) { }) } }) - -