Skip to content

Commit

Permalink
use for stations
Browse files Browse the repository at this point in the history
  • Loading branch information
boshek committed Oct 4, 2024
1 parent 468850e commit 638ffc8
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions R/realtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,12 @@ realtime_stations <- function(prov_terr_state_loc = NULL) {

url_check <- httr::GET(realtime_link, httr::user_agent("https://github.com/ropensci/tidyhydat"))

## Checking to make sure the link is valid
if (httr::http_error(url_check) == "TRUE") {
stop(paste0(realtime_link, " is not a valid url. Datamart may be down or the url has changed."))
}

if (is_mac()) {
# temporary patch to work around vroom 1.6.4 bug
readr::local_edition(1)
}
req <- httr2::request(realtime_link)
resp <- tidyhydat_perform(req)
resp_str <- httr2::resp_body_string(resp)

net_tibble <- httr::content(url_check,
type = "text/csv",
encoding = "UTF-8",
net_tibble <- readr::read_csv(
resp_str,
skip = 1,
col_names = c(
"STATION_NUMBER",
Expand All @@ -141,7 +134,7 @@ realtime_stations <- function(prov_terr_state_loc = NULL) {
}


as.realtime(dplyr::filter(net_tibble, PROV_TERR_STATE_LOC %in% prov))
as.realtime(net_tibble[net_tibble$PROV_TERR_STATE_LOC %in% prov, ])
}

#' Add local datetime column to realtime tibble
Expand Down

0 comments on commit 638ffc8

Please sign in to comment.