Skip to content

Commit

Permalink
reducing api calls (#19)
Browse files Browse the repository at this point in the history
Merge branch 'Chrisjb-master'
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
evanodell committed Feb 2, 2020
2 parents 7047fa6 + 68c920f commit 3c80c6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(nomis_overview)
export(nomis_search)
importFrom(dplyr,bind_rows)
importFrom(httr,GET)
importFrom(httr,content)
importFrom(httr,http_error)
importFrom(httr,http_type)
importFrom(httr,status_code)
Expand Down
2 changes: 1 addition & 1 deletion R/nomisr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @name nomisr
#' @importFrom jsonlite fromJSON
#' @importFrom tibble as_tibble enframe
#' @importFrom httr http_type GET http_error status_code
#' @importFrom httr http_type GET http_error status_code content
#' @importFrom readr read_csv col_double col_character
#' @importFrom dplyr bind_rows
#' @importFrom utils menu
Expand Down
14 changes: 4 additions & 10 deletions R/utils-get-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ nomis_get_data_util <- function(query) {
}

df <- tryCatch({
readr::read_csv(
api_get$url,
col_types = readr::cols(
.default = "c"
)
)
httr::content(api_get)
},
error = function(cond) {
message(
Expand All @@ -48,8 +43,7 @@ nomis_get_data_util <- function(query) {
if ("OBS_VALUE" %in% names(df)) {
df$OBS_VALUE <- as.double(df$OBS_VALUE)
}

df


}

}

0 comments on commit 3c80c6a

Please sign in to comment.