Skip to content

Commit

Permalink
fix(get_hydrometrie_observations_tr): crashes when returns empty result
Browse files Browse the repository at this point in the history
Closes #47
  • Loading branch information
DDorch committed Dec 1, 2024
1 parent b91a7ed commit 006610d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
5 changes: 2 additions & 3 deletions R/get_hydrometrie.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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))
}


Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-run_all_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ lapply(db, function(Rd_fun) {
})
}
})


0 comments on commit 006610d

Please sign in to comment.