diff --git a/R/connection.R b/R/connection.R index 2cd2a96..b77b09a 100644 --- a/R/connection.R +++ b/R/connection.R @@ -41,7 +41,9 @@ connect_fram_db <- fram_db_species <- fram_database_species(con) - rlang::inform('Successfully connected to FRAM database') + cli::cli_alert_success('Successfully connected to FRAM database') + + welcome(con) return( list( @@ -65,6 +67,6 @@ connect_fram_db <- disconnect_fram_db <- function(fram_db){ db_var_name <- deparse(substitute(fram_db)) DBI::dbDisconnect(fram_db$fram_db_connection) - rlang::inform(glue::glue('Successfully disconnected from FRAM database ({db_var_name})')) + cli::cli_alert_success(glue::glue('Successfully disconnected from FRAM database ({db_var_name})')) } diff --git a/R/integrity.R b/R/integrity.R index 5abde2f..cdd7271 100644 --- a/R/integrity.R +++ b/R/integrity.R @@ -207,3 +207,29 @@ run_info <- function(fram_db, run_id = NULL) { } +#' Welcome message +#' @param con FRAM database connection +#' @examples +#' \dontrun{welcome(con)} +#' +welcome <- function(con){ + runs <- DBI::dbReadTable(con, 'RunID') |> + tibble::as_tibble() |> + janitor::clean_names() + + species <- unique(runs$species_name) + run_count <- nrow(runs) + last_run <- format(max(runs$run_time_date), '%a, %B %d, %Y %I:%M %p') + last_modify_input <- format(max(runs$modify_input_date), '%a, %B %d, %Y %I:%M %p') + last_run_name <- runs |> + dplyr::filter(.data$run_time_date == max(runs$run_time_date)) |> + dplyr::pull(.data$run_name) + + cli::cli_text(cat(cli::col_blue('Database Species: '), cli::col_grey(species))) + cli::cli_text(cat(cli::col_blue('Run Count: '), cli::col_grey(run_count))) + cli::cli_text(cat(cli::col_blue('Last Run Date: '), cli::col_grey(last_run))) + cli::cli_text(cat(cli::col_blue('Last Run Name: '), cli::col_grey(last_run_name))) + cli::cli_text(cat(cli::col_blue('Last Modify Date: '), cli::col_grey(last_modify_input))) + +} + diff --git a/man/welcome.Rd b/man/welcome.Rd new file mode 100644 index 0000000..b359ea2 --- /dev/null +++ b/man/welcome.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/integrity.R +\name{welcome} +\alias{welcome} +\title{Welcome message} +\usage{ +welcome(con) +} +\arguments{ +\item{con}{FRAM database connection} +} +\description{ +Welcome message +} +\examples{ +\dontrun{welcome(con)} + +}