Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve reading of EPIDATR_USE_CACHE variable #273

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: epidatr
Type: Package
Title: Client for Delphi's 'Epidata' API
Version: 1.1.3
Version: 1.1.4
Authors@R:
c(
person("Logan", "Brooks", email = "[email protected]", role = c("aut")),
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# epidatr 1.2.0
dsweber2 marked this conversation as resolved.
Show resolved Hide resolved

## Changes

- Improve handling of the `EPIDATR_USE_CACHE` environment variable, allowing it
to be any value convertable by `as.logical()` and handle the case when it
can't be converted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please include PR number here

Suggested change
can't be converted.
can't be converted (#273).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah my bad, I set it up to auto-merge, let's add this in a next PR


# epidatr 1.1.1

## Changes

## Features

## Patches

- Fix failure when passing `as_of` values in `Date` format to
`pub_covidcast` while caching is enabled (#259).
- For `pub_covidcast` data source `nchs-mortality`, parse dates as `epiweek`
Expand All @@ -15,21 +24,26 @@
# epidatr 1.1.0

## Changes

- `pub_covid_hosp_state_timeseries` now supports use of the `as_of` parameter (#209).
- `release_date` and `latest_update` fields are now parsed as `Date`, rather
than as text. This change impacts several endpoints.
- `get_auth_key` renamed to `get_api_key` (#181).
- `get_api_key` no longer reads from R options and only uses environment variables (#217).
- `pvt_twitter` and `pub_wiki` now use `time_type` and `time_values` args instead of mutually exclusive `dates` and `epiweeks` (#236). This matches the interface of the `pub_covidcast` endpoint.
- Updated the default `timeout_seconds` to 15 minutes to allow large queries by default.

## Features

- Function reference now displays commonly-used functions first (#205).
- Support `Date` objects passed to version arguments `as_of` and `issues` in
endpoints (#192, #194).
- `clear_cache` now handles positional arguments just like `set_cache` (#197).
- `set_api_key` now available to help persist API key environment variables (#181, #217).
- All endpoints now support the use of "\*" as a wildcard to fetch all dates or epiweeks (#234).

## Patches

- Endpoints now fail when passed misspelled arguments (#187, #201).
- `pub_fluview_meta` fixed to `fetch` the response automatically.
- `pub_covid_hosp_state_timeseries` now correctly parses the `issue` field,
Expand Down
10 changes: 8 additions & 2 deletions R/epidatr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
"_PACKAGE"

.onLoad <- function(libname, pkgname) {
cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)
cache_environ$use_cache <- (cache_environ$use_cache == "TRUE")
cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE))
if (is.na(cache_environ$use_cache)) {
cli::cli_warn(
"Failed to read EPIDATR_USE_CACHE environment variable.
Should be a logical. Defaulting to FALSE."
)
cache_environ$use_cache <- FALSE
}
if (cache_environ$use_cache) {
set_cache(startup = TRUE)
}
Expand Down
Loading