Skip to content

Commit dda806d

Browse files
authored
Merge pull request #135 from surveydown-dev/cran-checks
v0.4.0 on CRAN!
2 parents 86c4d05 + 5765bb2 commit dda806d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1959
-951
lines changed

.Rbuildignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ surveydown.Rproj
1414
^doc$
1515
^Meta$
1616
build.R
17-
data-raw
1817
^cran-comments\.md$
1918
^\.travis\.yml$
2019
^CRAN-RELEASE$
2120
^CRAN-SUBMISSION$
2221
^.vscode$
2322
^app.R$
24-
^survey.qmd$
25-
^_extensions$
26-
^data.csv$

CRAN-SUBMISSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Version: 0.4.0
2+
Date: 2024-10-29 15:25:55 UTC
3+
SHA: 7a2d4b79cd90a1133c70ca18bc328785fc4dd2e2

DESCRIPTION

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: surveydown
2-
Title: Markdown-Based Surveys Using Quarto Shiny Documents
3-
Version: 0.3.7
2+
Title: Markdown-Based Surveys Using 'Quarto' and 'shiny'
3+
Version: 0.4.0
44
Authors@R: c(
55
person(given = "John Paul",
66
family = "Helveston",
@@ -17,7 +17,7 @@ Authors@R: c(
1717
role = c("aut", "cph"),
1818
email = "buneabt@yahoo.com",
1919
comment = c(ORCID = "0009-0006-2942-0588")))
20-
Description: Generate surveys using markdown and R code chunks. Surveys are defined as Quarto shiny documents that render to shiny apps. Survey data collected from respondents is stored in a supabase database. Features include controls for conditional skip logic (skip to a page based on an answer to a question), conditional display logic (display a question based on an answer to a question), the ability to export time stamps (both for each page and each question interaction), a customizable progress bar, and a wide variety of question types, including multiple choice (single choice and multiple choices), select, text, numeric, multiple choice buttons, text area, and dates.
20+
Description: Generate surveys using markdown and R code chunks. Surveys are composed of two files: a survey.qmd 'Quarto' file defining the survey content (pages, questions, etc), and an app.R file defining a 'shiny' app with global settings (libraries, database configuration, etc.) and server configuration options (e.g., conditional skipping / display, etc.). Survey data collected from respondents is stored in a 'PostgreSQL' database. Features include controls for conditional skip logic (skip to a page based on an answer to a question), conditional display logic (display a question based on an answer to a question), a customizable progress bar, and a wide variety of question types, including multiple choice (single choice and multiple choices), select, text, numeric, multiple choice buttons, text area, and dates.
2121
License: MIT + file LICENSE
2222
Encoding: UTF-8
2323
LazyData: true
@@ -32,15 +32,12 @@ Suggests:
3232
glue
3333
Imports:
3434
DBI,
35-
digest,
3635
DT,
3736
htmltools,
3837
markdown,
3938
pool,
4039
quarto,
41-
remotes,
4240
RPostgres,
43-
rsconnect,
4441
rstudioapi,
4542
rvest,
4643
shiny,

NAMESPACE

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export(sd_completion_code)
77
export(sd_copy_value)
88
export(sd_create_survey)
99
export(sd_database)
10-
export(sd_deploy)
1110
export(sd_display_question)
1211
export(sd_display_value)
1312
export(sd_get_data)
@@ -26,25 +25,4 @@ export(sd_show_password)
2625
export(sd_skip_if)
2726
export(sd_store_value)
2827
export(sd_ui)
29-
export(sd_update)
3028
export(sd_version)
31-
import(rstudioapi)
32-
import(shiny)
33-
import(shinyWidgets)
34-
importFrom(digest,digest)
35-
importFrom(rsconnect,deployApp)
36-
importFrom(shiny,HTML)
37-
importFrom(shiny,actionButton)
38-
importFrom(shiny,getDefaultReactiveDomain)
39-
importFrom(shiny,observeEvent)
40-
importFrom(shiny,parseQueryString)
41-
importFrom(shiny,reactive)
42-
importFrom(shiny,reactiveValuesToList)
43-
importFrom(shiny,renderText)
44-
importFrom(shiny,renderUI)
45-
importFrom(shiny,tags)
46-
importFrom(stats,setNames)
47-
importFrom(usethis,ui_info)
48-
importFrom(usethis,ui_oops)
49-
importFrom(usethis,ui_todo)
50-
importFrom(usethis,ui_yeah)

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# surveydown (development version)
22

3+
# surveydown 0.4.0
4+
5+
- All examples updated to include run-able examples (where possible).
6+
- Added example survey.qmd files in inst/examples (for use in function examples).
7+
- All roxygen documentation reviewed for errors / typos.
8+
- Removed `sd_update()` function.
9+
- Removed `sd_deploy()` function.
10+
- Installation instructions updated.
11+
312
# surveydown 0.3.7
413

514
- Updated `sd_output()` to now be able to output the chosen question values, chosen question option label(s), and the question label itself. Addresses feature request #128.

R/config.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ get_question_structure <- function(html_content) {
247247

248248
get_output_ids <- function() {
249249
output <- shiny::getDefaultReactiveDomain()$output
250-
outs <- outputOptions(output)
250+
outs <- shiny::outputOptions(output)
251251
return(names(outs))
252252
}
253253

R/db.R

Lines changed: 70 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
#' Connect to a Supabase Database with Automatic Cleanup
1+
#' Connect to a 'PostgreSQL' Database with Automatic Cleanup
22
#'
3-
#' This function establishes a connection pool to a Supabase database and sets
4-
#' up automatic cleanup when the Shiny session ends.
3+
#' This function establishes a connection pool to a 'PostgreSQL' database
4+
#' (e.g. Supabase) and sets up automatic cleanup when the 'shiny' session ends.
55
#'
66
#' @param host Character string. The host address of the Supabase database.
77
#' @param dbname Character string. The name of the Supabase database.
88
#' @param port Integer. The port number for the Supabase database connection.
99
#' @param user Character string. The username for the Supabase database
10-
#' connection.
10+
#' connection.
1111
#' @param table Character string. The name of the table to interact with in
12-
#' the Supabase database.
12+
#' the Supabase database.
1313
#' @param password Character string. The password for the Supabase database
14-
#' connection. NOTE: While you can provide a hard-coded password here, we do
15-
#' NOT recommend doing so for security purposes. Instead, you should establish
16-
#' a password with `surveydown::sd_set_password()`, which will create a local
17-
#' .Renviron file that stores you password as a SURVEYDOWN_PASSWORD environment
18-
#' variable. The `password` argument uses this as the default value, so if you
19-
#' set a password properly with `surveydown::sd_set_password()`, then you can
20-
#' safely ignore using the `password` argument here.
14+
#' connection. NOTE: While you can provide a hard-coded password here, we do
15+
#' NOT recommend doing so for security purposes. Instead, you should establish
16+
#' a password with `surveydown::sd_set_password()`, which will create a local
17+
#' `.Renviron` file that stores your password as a `SURVEYDOWN_PASSWORD`
18+
#' environment
19+
#' variable. The `password` argument uses this as the default value, so if you
20+
#' set a password properly with `surveydown::sd_set_password()`, then you can
21+
#' safely ignore using the `password` argument here.
2122
#' @param gssencmode Character string. The GSS encryption mode for the database
22-
#' connection. Defaults to `"prefer"`. NOTE: If you have verified all
23-
#' connection details are correct but still cannot access the database,
24-
#' consider setting this to `"disable"`. This can be necessary if you're on a
25-
#' secure connection, such as a VPN.
26-
#' @param ignore Logical. If TRUE, data will be saved to a local CSV file instead of the database. Defaults to FALSE.
27-
#' @param min_size Integer. The minimum number of connections in the pool. Defaults to 1.
28-
#' @param max_size Integer. The maximum number of connections in the pool. Defaults to Inf.
23+
#' connection. Defaults to `"prefer"`. NOTE: If you have verified all
24+
#' connection details are correct but still cannot access the database,
25+
#' consider setting this to `"disable"`. This can be necessary if you're on a
26+
#' secure connection, such as a VPN.
27+
#' @param ignore Logical. If `TRUE`, data will be saved to a local CSV file
28+
#' instead of the database. Defaults to `FALSE`.
29+
#' @param min_size Integer. The minimum number of connections in the pool.
30+
#' Defaults to 1.
31+
#' @param max_size Integer. The maximum number of connections in the pool.
32+
#' Defaults to `Inf`.
2933
#'
30-
#' @return A list containing the database connection pool (`db`) and the table name (`table`),
31-
#' or NULL if in ignore mode or if there's an error.
34+
#' @return A list containing the database connection pool (`db`) and the table
35+
#' name (`table`), or `NULL` if in ignore mode or if there's an error.
3236
#'
3337
#' @examples
34-
#' \dontrun{
38+
#' if (interactive()) {
3539
#' # Assuming SURVEYDOWN_PASSWORD is set in .Renviron
36-
#' db_connection <- sd_database(
37-
#' host = "aws-0-us-west-1.pooler.supabase.com",
38-
#' dbname = "postgres",
39-
#' port = "6---",
40-
#' user = "postgres.k----------i",
41-
#' table = "your-table-name",
42-
#' ignore = FALSE
40+
#' db <- sd_database(
41+
#' host = "aws-0-us-west-1.pooler.supabase.com",
42+
#' dbname = "postgres",
43+
#' port = "6---",
44+
#' user = "postgres.k----------i",
45+
#' table = "your-table-name",
46+
#' ignore = FALSE
4347
#' )
4448
#'
45-
#' # Explicitly providing the password
46-
#' db_connection <- sd_database(
47-
#' host = "aws-0-us-west-1.pooler.supabase.com",
48-
#' dbname = "postgres",
49-
#' port = "6---",
50-
#' user = "postgres.k----------i",
51-
#' table = "your-table-name",
52-
#' password = "your-password",
53-
#' ignore = FALSE
54-
#' )
55-
#' }
49+
#' # Print the structure of the connection
50+
#' str(db)
5651
#'
52+
#' # Close the connection pool when done
53+
#' if (!is.null(db)) {
54+
#' pool::poolClose(db$db)
55+
#' }
56+
#' }
5757
#' @export
5858
sd_database <- function(
5959
host = NULL,
@@ -120,38 +120,47 @@ sd_database <- function(
120120
#'
121121
#' This function retrieves all data from a specified table in a database.
122122
#' It automatically detects whether it's being used in a reactive context
123-
#' (e.g., within a Shiny application) and behaves accordingly. In a reactive
123+
#' (e.g., within a 'shiny' application) and behaves accordingly. In a reactive
124124
#' context, it returns a reactive expression that automatically refreshes
125125
#' the data at specified intervals.
126126
#'
127-
#' @param db A list containing database connection details. Must have elements:
127+
#' @param db A list containing database connection details created using
128+
#' `sd_database()`. Must have elements:
128129
#' \itemize{
129-
#' \item db: A DBI database connection object
130-
#' \item table: A string specifying the name of the table to query
130+
#' \item `db`: A `DBI` database connection object
131+
#' \item `table`: A string specifying the name of the table to query
131132
#' }
132-
#' @param refresh_interval Numeric. The time interval (in seconds) between data refreshes
133-
#' when in a reactive context. Default is `NULL`, meaning the data will not refresh.
134-
#'
135-
#' @return In a non-reactive context, returns a data frame containing all rows and columns
136-
#' from the specified table. In a reactive context, returns a reactive expression that,
137-
#' when called, returns the most recent data from the specified database table.
133+
#' @param refresh_interval Numeric. The time interval (in seconds) between data
134+
#' refreshes when in a reactive context. Default is `NULL`, meaning the data
135+
#' will not refresh.
138136
#'
139-
#' @export
137+
#' @return In a non-reactive context, returns a data frame containing all rows
138+
#' and columns from the specified table. In a reactive context, returns a
139+
#' reactive expression that, when called, returns the most recent data from
140+
#' the specified database table.
140141
#'
141142
#' @examples
143+
#' # Non-reactive context example
142144
#' \dontrun{
143-
#' # Non-reactive context
144-
#' db <- list(db = DBI::dbConnect(...), table = "my_table")
145-
#' data <- sd_get_data(db)
145+
#' library(surveydown)
146146
#'
147-
#' # Reactive context (inside a Shiny server function)
148-
#' server <- function(input, output, session) {
149-
#' data <- sd_get_data(db, refresh_interval = 10)
150-
#' output$table <- renderTable({
151-
#' data() # Note the parentheses to retrieve the reactive value
152-
#' })
153-
#' }
147+
#' # Assuming you have a database connection called db created using
148+
#' # sd_database(), you can fetch data with:
149+
#'
150+
#' data <- sd_get_data(db)
151+
#' head(data)
152+
#'
153+
#' # Reactive context example (inside a surveydown app)
154+
#'
155+
#' server <- function(input, output, session) {
156+
#' data <- sd_get_data(db, refresh_interval = 10)
157+
#'
158+
#' output$data_table <- renderTable({
159+
#' data() # Note the parentheses to retrieve the reactive value
160+
#' })
161+
#' }
154162
#' }
163+
#' @export
155164
sd_get_data <- function(db, refresh_interval = NULL) {
156165
if (is.null(db)) {
157166
warning("Database is not connected, db is NULL")

0 commit comments

Comments
 (0)