It would be nice to have automated reporting of which hosts are running outdated modules. This may also serve as a precursor to sync_module_settings_between_projects, though it looks like that will
Here's a very basic implementation:
#' Get all module setting information
#'
#' @param conn a DBI database connection to a REDCap database
#'
#' @return A dataframe of all module settings on the specified host
#'
#' @export
#' @examples
#' \dontrun{
#' conn <- get_redcap_db_connection()
#' module_settings <- get_redcap_module_settings(conn)
#' }
get_redcap_module_settings <- function(conn) {
sql <- paste("SELECT * FROM redcap_external_modules as em",
"INNER JOIN (SELECT * FROM redcap_external_module_settings) as ems",
"ON em.external_module_id = ems.external_module_id"
)
df <- DBI::dbGetQuery(conn, sql)
# note external_module_id is duplicated,
return(df)
}
And here is a use case:
library(tidyverse)
library(redcapcustodian)
library(dotenv)
load_dot_env("testing.env")
conn <- connect_to_redcap_db()
module_versions_on_host <- get_redcap_module_settings(conn) %>%
filter(key == "version") %>%
select(directory_prefix, version = value) %>%
mutate(host = Sys.getenv("INSTANCE"))
DBI::dbDisconnect(conn)
# repeat this over a list of env files, rbind to get a complete list of module settings on each host
# Get latest tag from org's repo for directory_prefix - possibly pull this from site dir - via github API
# anti_join or filter with module_versions_on_host to get outdated modules
It would be nice to have automated reporting of which hosts are running outdated modules. This may also serve as a precursor to
sync_module_settings_between_projects
, though it looks like that willHere's a very basic implementation:
And here is a use case: