Skip to content

Commit

Permalink
Merge pull request #145 from surveydown-dev/cookie-revert
Browse files Browse the repository at this point in the history
Cookie reapply
  • Loading branch information
pingfan-hu authored Nov 28, 2024
2 parents 217074e + c02b90d commit a4046c2
Show file tree
Hide file tree
Showing 7 changed files with 797 additions and 575 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: surveydown
Title: Markdown-Based Surveys Using 'Quarto' and 'shiny'
Version: 0.5.1
Version: 0.5.2
Authors@R: c(
person(given = "John Paul",
family = "Helveston",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# surveydown (development version)

# surveydown 0.5.2

- Cookies feature fixed.

# surveydown 0.5.1

- Revert mostly to v0.4.2 to completely remove the cookies feature added in v0.5.0. Will re-implement a new approach in a later version.
Expand Down
9 changes: 4 additions & 5 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ run_config <- function(
question_structure <- get_question_structure(paths, html_content)

message(
"Survey rendered and saved to '", paths$target_html,
". Extracted content saved to '", paths$target_pages, "', '",
paths$target_head, "', and '", paths$target_questions, "' files."
'Survey rendered and saved to "', paths$target_html,
'. Extracted content saved to "', paths$target_pages, '", "',
paths$target_head, '", and "', paths$target_questions, '" files.'
)

} else {
message(
"No changes detected in 'survey.qmd' or 'app.R' files. ",
"Importing survey content from '_survey' folder."
'No changes detected. Importing contents from "_survey" folder.'
)

# Load head content from _survey folder
Expand Down
14 changes: 13 additions & 1 deletion R/db.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,23 @@ sd_get_data <- function(db, refresh_interval = NULL) {
warning("Database is not connected, db is NULL")
return(NULL)
}

fetch_data <- function() {
# Check if table exists first
table_exists <- pool::poolWithTransaction(db$db, function(conn) {
DBI::dbExistsTable(conn, db$table)
})

if (!table_exists) {
return(NULL)
}

# Only try to read if table exists
pool::poolWithTransaction(db$db, function(conn) {
DBI::dbReadTable(conn, db$table)
})
}

if (!is.null(refresh_interval)) {
if (is.null(shiny::getDefaultReactiveDomain())) {
stop('If refresh_interval is set to a positive number, sd_get_data() must be called within a reactive context for the data to continously update in the server.')
Expand Down Expand Up @@ -228,7 +240,7 @@ create_table <- function(data_list, db, table) {
DBI::dbExecute(conn, paste0('ALTER TABLE "', table, '" ENABLE ROW LEVEL SECURITY;'))
})

message(paste("Table", table, "created in the database."))
message(paste0('Table "', table, '" created in the database.'))
}

# Solution found in this issue:
Expand Down
Loading

0 comments on commit a4046c2

Please sign in to comment.