Skip to content

Commit b123fed

Browse files
Merge pull request #842 from ldecicco-USGS/develop
Develop
2 parents 872d4fe + 89ccf9c commit b123fed

File tree

5 files changed

+48
-25
lines changed

5 files changed

+48
-25
lines changed

R/construct_api_requests.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ basic_request <- function(url_base, format = "json"){
436436
httr2::req_headers(`Accept-Encoding` = c("compress", "gzip")) |>
437437
httr2::req_url_query(f = format,
438438
lang = "en-US") |>
439-
httr2::req_error(body = error_body)
439+
httr2::req_error(body = error_body) |>
440+
httr2::req_timeout(seconds = 180)
440441

441442
token <- Sys.getenv("API_USGS_PAT")
442443

R/get_ogc_data.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ get_ogc_data <- function(args,
3232
no_paging <- FALSE
3333
}
3434

35+
message("Requesting:\n", req$url)
36+
3537
if(no_paging){
3638
return_list <- get_csv(req, limit = args[["limit"]])
3739
} else {

R/read_waterdata_ts_meta.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
#' @param computation_period_identifier `r get_params("time-series-metadata")$computation_period_identifier`
1212
#' @param sublocation_identifier `r get_params("time-series-metadata")$sublocation_identifier`
1313
#' @param last_modified `r get_params("time-series-metadata")$last_modified`
14-
#' @param begin `r get_params("time-series-metadata")$begin`
15-
#' @param end `r get_params("time-series-metadata")$end`
14+
#' @param begin_utc `r get_params("time-series-metadata")$begin_utc`
15+
#' @param end_utc `r get_params("time-series-metadata")$end_utc`
1616
#' @param hydrologic_unit_code `r get_params("time-series-metadata")$hydrologic_unit_code`
1717
#' @param state_name `r get_params("time-series-metadata")$state_name`
1818
#' @param thresholds `r get_params("time-series-metadata")$thresholds`
1919
#' @param unit_of_measure `r get_params("time-series-metadata")$unit_of_measure`
2020
#' @param primary `r get_params("time-series-metadata")$primary`
2121
#' @param parent_time_series_id `r get_params("time-series-metadata")$parent_time_series_id`
2222
#' @param web_description `r get_params("time-series-metadata")$web_description`
23+
#' @param begin `r get_params("time-series-metadata")$begin`
24+
#' @param end `r get_params("time-series-metadata")$end`
2325
#' @param properties A vector of requested columns to be returned from the query.
2426
#' Available options are:
2527
#' `r dataRetrieval:::get_properties_for_docs("time-series-metadata", "time_series_id")`.
@@ -58,8 +60,8 @@
5860
#' parameter_code = c("00060", "00010"),
5961
#' properties = c("monitoring_location_id",
6062
#' "parameter_code",
61-
#' "begin",
62-
#' "end",
63+
#' "begin_utc",
64+
#' "end_utc",
6365
#' "time_series_id"),
6466
#' skipGeometry = TRUE)
6567
#'
@@ -71,8 +73,8 @@ read_waterdata_ts_meta <- function(monitoring_location_id = NA_character_,
7173
properties = NA_character_,
7274
statistic_id = NA_character_,
7375
last_modified = NA_character_,
74-
begin = NA_character_,
75-
end = NA_character_,
76+
begin_utc = NA_character_,
77+
end_utc = NA_character_,
7678
hydrologic_unit_code = NA_character_,
7779
state_name = NA_character_,
7880
unit_of_measure = NA_character_,
@@ -88,6 +90,8 @@ read_waterdata_ts_meta <- function(monitoring_location_id = NA_character_,
8890
limit = NA,
8991
max_results = NA,
9092
bbox = NA,
93+
begin = NA_character_,
94+
end = NA_character_,
9195
convertType = TRUE,
9296
no_paging = FALSE){
9397

R/walk_pages.R

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@
55
#' @noRd
66
#' @return data.frame with attributes
77
walk_pages <- function(req){
8-
9-
message("Requesting:\n", req$url)
108

119
resps <- httr2::req_perform_iterative(req,
1210
next_req = next_req_url,
13-
max_reqs = Inf, on_error = "return")
14-
failures <- resps |>
15-
httr2::resps_failures() |>
16-
httr2::resps_requests()
17-
18-
if(length(failures) > 0){
19-
stop(resps[[1]][["message"]])
20-
}
21-
11+
max_reqs = Inf, on_error = "stop")
12+
2213
return_list <- data.frame()
2314
for(resp in resps){
2415
df1 <- get_resp_data(resp)
@@ -105,7 +96,6 @@ next_req_url <- function(resp, req) {
10596

10697
get_csv <- function(req, limit){
10798

108-
message("Requesting:\n", req$url)
10999
skip_geo <- grepl("skipGeometry=true", req$url, ignore.case = TRUE)
110100
resp <- httr2::req_perform(req)
111101

man/read_waterdata_ts_meta.Rd

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)