add working dir to queries

This commit is contained in:
2025-12-25 02:03:27 -05:00
parent 61af76b805
commit d763bc1ea0
+9 -3
View File
@@ -6,6 +6,9 @@ library(DBI)
library(xts)
library(memoise)
library(cachem)
library(digest)
APP_DIR <- getwd()
config <- config::get(file = "config.yml")
@@ -615,15 +618,18 @@ get_county_and_state <- function(df) {
return(result)
}
cache_dir <- "cache"
cache_dir <- file.path(APP_DIR, "cache")
cache_logfile <- file.path(APP_DIR, "cachelog")
if (!dir.exists(cache_dir)) {
dir.create(cache_dir, recursive = TRUE)
}
query_cache <- cachem::cache_disk(
dir = cache_dir,
max_size = 1000 * 1024^2,
evict = "lru"
max_age = 86400, # 24 hours
evict = "lru",
logfile = cache_logfile
)
get_yearly_economics <- memoise(get_yearly_economics, cache = query_cache)