Skip to content

Commit 6b98373

Browse files
authored
Merge pull request #273 from cmu-delphi/ds/cache-fix
fix: improve reading of `EPIDATR_USE_CACHE` variable
2 parents 1ae608d + a6265f1 commit 6b98373

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: epidatr
22
Type: Package
33
Title: Client for Delphi's 'Epidata' API
4-
Version: 1.1.3
4+
Version: 1.1.4
55
Authors@R:
66
c(
77
person("Logan", "Brooks", email = "[email protected]", role = c("aut")),

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
# epidatr 1.2.0
2+
3+
## Changes
4+
5+
- Improve handling of the `EPIDATR_USE_CACHE` environment variable, allowing it
6+
to be any value convertable by `as.logical()` and handle the case when it
7+
can't be converted.
8+
19
# epidatr 1.1.1
210

311
## Changes
412

513
## Features
614

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

1726
## Changes
27+
1828
- `pub_covid_hosp_state_timeseries` now supports use of the `as_of` parameter (#209).
1929
- `release_date` and `latest_update` fields are now parsed as `Date`, rather
2030
than as text. This change impacts several endpoints.
2131
- `get_auth_key` renamed to `get_api_key` (#181).
2232
- `get_api_key` no longer reads from R options and only uses environment variables (#217).
2333
- `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.
2434
- Updated the default `timeout_seconds` to 15 minutes to allow large queries by default.
35+
2536
## Features
37+
2638
- Function reference now displays commonly-used functions first (#205).
2739
- Support `Date` objects passed to version arguments `as_of` and `issues` in
2840
endpoints (#192, #194).
2941
- `clear_cache` now handles positional arguments just like `set_cache` (#197).
3042
- `set_api_key` now available to help persist API key environment variables (#181, #217).
3143
- All endpoints now support the use of "\*" as a wildcard to fetch all dates or epiweeks (#234).
44+
3245
## Patches
46+
3347
- Endpoints now fail when passed misspelled arguments (#187, #201).
3448
- `pub_fluview_meta` fixed to `fetch` the response automatically.
3549
- `pub_covid_hosp_state_timeseries` now correctly parses the `issue` field,

R/epidatr-package.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
"_PACKAGE"
99

1010
.onLoad <- function(libname, pkgname) {
11-
cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)
12-
cache_environ$use_cache <- (cache_environ$use_cache == "TRUE")
11+
cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE))
12+
if (is.na(cache_environ$use_cache)) {
13+
cli::cli_warn(
14+
"Failed to read EPIDATR_USE_CACHE environment variable.
15+
Should be a logical. Defaulting to FALSE."
16+
)
17+
cache_environ$use_cache <- FALSE
18+
}
1319
if (cache_environ$use_cache) {
1420
set_cache(startup = TRUE)
1521
}

0 commit comments

Comments
 (0)