From a16be72813c19113a0c27bf3a651e8ef79b40395 Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Mon, 13 Jan 2020 11:58:04 -0500 Subject: [PATCH] fixups for scrapers; added cache/refresh for mysql and etcd --- R/openresty.R | 15 +++++++++++++-- man/openresty_version_history.Rd | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/R/openresty.R b/R/openresty.R index ab1effb..126499d 100644 --- a/R/openresty.R +++ b/R/openresty.R @@ -7,9 +7,15 @@ #' ordered factor. #' #' @md +#' @param refresh if `TRUE` and there `~/.vershist` cache dir exists, will +#' cause the version history database for apache to be rebuilt. Defaults +#' to `FALSE` and has no effect if `~/.vershist` cache dir does not exist. #' @note This function requires a valid GitHub API key stored in `GITHUB_PAT` #' @export -openresty_version_history <- function() { +openresty_version_history <- function(refresh = FALSE) { + + tech <- "openresty" + if (use_cache() && (!refresh) && is_cached(tech)) return(read_from_cache(tech)) page <- gh::gh("/repos/openresty/openresty/tags") @@ -52,6 +58,11 @@ openresty_version_history <- function() { dplyr::mutate_at(.vars=c("major", "minor", "patch", "build"), .funs=c(as.integer)) %>% dplyr::arrange(major, minor, patch) %>% dplyr::mutate(vers = factor(vers, levels=vers)) %>% - dplyr::select(vers, rls_date, rls_year, major, minor, patch, prerelease, build) + dplyr::select(vers, rls_date, rls_year, major, minor, patch, prerelease, build) -> out + + + if (use_cache() && (refresh || (!is_cached(tech)))) write_to_cache(out, tech) + + out } \ No newline at end of file diff --git a/man/openresty_version_history.Rd b/man/openresty_version_history.Rd index 4f810b1..f6f16ab 100644 --- a/man/openresty_version_history.Rd +++ b/man/openresty_version_history.Rd @@ -4,7 +4,12 @@ \alias{openresty_version_history} \title{Retrieve openresty Version Release History} \usage{ -openresty_version_history() +openresty_version_history(refresh = FALSE) +} +\arguments{ +\item{refresh}{if \code{TRUE} and there \verb{~/.vershist} cache dir exists, will +cause the version history database for apache to be rebuilt. Defaults +to \code{FALSE} and has no effect if \verb{~/.vershist} cache dir does not exist.} } \description{ Reads \url{https://github.com/openresty/openresty/releases} to build a data frame of