Skip to content

Commit

Permalink
Merge pull request #66 from jhelvy/pingfan-ui-design
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
pingfan-hu authored Aug 8, 2024
2 parents 7435280 + 0bdd29d commit b9ea8a2
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 54 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ Imports:
DBI,
markdown,
readr,
remotes,
RPostgres,
rvest,
shiny,
shinyjs,
shinyWidgets,
usethis
shinyWidgets,
usethis,
utils,
yaml
URL: https://github.com/jhelvy/surveydown
BugReports: https://github.com/jhelvy/surveydown/issues
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export(sd_setup)
export(sd_update_extension)
export(sd_update_surveydown)
importFrom(utils,packageDescription)
importFrom(utils,packageVersion)
35 changes: 17 additions & 18 deletions R/db.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
#' Connect to a SupaBase Database
#' Connect to a supabase Database
#'
#' This function establishes a connection to a SupaBase database using the provided
#' This function establishes a connection to a supabase database using the provided
#' connection details.
#'
#' @param host Character string. The host address of the SupaBase database.
#' @param db_name Character string. The name of the SupaBase database.
#' @param port Integer. The port number for the SupaBase database connection.
#' @param user Character string. The username for the SupaBase database connection.
#' @param table_name Character string. The name of the table to interact with in the SupaBase database.
#' @param password Character string. The password for the SupaBase database connection.
#' @param host Character string. The host address of the supabase database.
#' @param db_name Character string. The name of the supabase database.
#' @param port Integer. The port number for the supabase database connection.
#' @param user Character string. The username for the supabase database connection.
#' @param table_name Character string. The name of the table to interact with in the supabase database.
#' @param password Character string. The password for the supabase database connection.
#' @param gssencmode Character string. The GSS encryption mode for the database connection. Defaults to "prefer".
#'
#' @details The function checks for the presence of all required parameters and attempts to
#' establish a connection to the SupaBase database. If successful, it returns a list containing
#' the database connection object and the table name. The user must have created the specified
#' table in SupaBase beforehand.
#' establish a connection to the supabase database. If successful, it returns a list containing
#'
#' @return A list containing the database connection object (`db`) and the table name (`table_name`).
#'
#' @note The user must create their own table inside SupaBase in order to make additions.
#' @note The user must create their own table inside supabase in order to make additions.
#'
#' @examples
#' \dontrun{
Expand All @@ -30,7 +29,7 @@
#' password = "your-password"
#' )
#'
#' #'Supabase Example PSQL Connect String
#' #'supabase Example PSQL Connect String
#' psql -h aws-0-us-west-1.pooler.supabase.com -p 6--- -d postgres -U postgres.k----------i
#'
#' db_connection <- sd_database(
Expand All @@ -51,7 +50,7 @@ sd_database <- function(
port = NULL,
user = NULL,
table_name = NULL,
password = NULL,
password = NULL,
gssencmode = "prefer"
) {

Expand All @@ -71,11 +70,11 @@ sd_database <- function(


if (!nchar(password)) {
stop("You must provide your SupaBase password to access the database")
stop("You must provide your supabase password to access the database")
}

# < Code to handle SupaBase authentication here >
#User Must create their own table inside of Supabase in order to make additions.
# < Code to handle supabase authentication here >
#User Must create their own table inside of supabase in order to make additions.
tryCatch(
{
db <- DBI::dbConnect(
Expand Down Expand Up @@ -160,7 +159,7 @@ create_table <- function(db, table_name, df) {
DBI::dbExecute(db, create_table_query)
#A precaution to enable RLS
DBI::dbExecute(db, paste0('ALTER TABLE \"', table_name, '\" ENABLE ROW LEVEL SECURITY;'))
return(message("Database should appear on your SupaBase Account (Can take up to a minute.)"))
return(message("Database should appear on your supabase Account (Can take up to a minute.)"))
}

database_uploading <- function(df, db, table_name) {
Expand Down
15 changes: 3 additions & 12 deletions R/version.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#' sd_update_surveydown()
#' sd_update_surveydown(force = TRUE)
#' }
#' @importFrom utils packageVersion
sd_update_surveydown <- function(force = FALSE) {
# Check R package version
pkg_version <- packageVersion("surveydown")
pkg_version <- utils::packageVersion("surveydown")

# Check Quarto extension version
ext_version <- get_extension_version()
Expand Down Expand Up @@ -48,16 +49,6 @@ sd_update_surveydown <- function(force = FALSE) {
}
}

#' Check Surveydown Versions
#'
#' This function checks if the local surveydown R package and Quarto extension
#' are up-to-date with the latest online version.
#'
#' @return No return value, called for side effects (prints version information).
#' @export
#'
#' @examples
#' sd_check_versions()
#' Check Surveydown Versions
#'
#' This function checks if the local surveydown R package and Quarto extension
Expand All @@ -70,7 +61,7 @@ sd_update_surveydown <- function(force = FALSE) {
#' sd_check_versions()
sd_check_versions <- function() {
# Get local versions
local_pkg_version <- packageVersion("surveydown")
local_pkg_version <- utils::packageVersion("surveydown")
local_ext_version <- get_extension_version()

# Get latest online versions
Expand Down
8 changes: 0 additions & 8 deletions man/sd_check_versions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions man/sd_database.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b9ea8a2

Please sign in to comment.