#' The application server-side
#'
#' @param input,output,session Internal parameters for {shiny}.
#' DO NOT REMOVE.
#' @import shiny
#' @import R6
#' @noRd
app_server <- function( input, output, session ) {
# Your application server logic
#-- 0. read config file
if (!exists("config")) config <<- config::get(file = app_sys("golem-config.yml"), use_parent = TRUE)
#-- 1. data
#-- 1.1 initiate R6 object
AwsBuffer <- R6Class(classname = "Buffer", list(
raw_dt = 0, # full data.table, input data
migrated_dt = 0, # user_logged == "production : DE : logged in" & migrated =="true"
time_dt = 0, # subset of columns: user_id, session_id, timestamp
sessions_enriched_dt = 0, # parsing info to get company nam, id, address, zip
cohort_users_dt = 0, # user_id's of users assigned to a cohort
cohort_sessions_dt = 0, # session_id's assigned to a cohort
sunburst_sessions_dt = 0,
pull_leads = function(dates_range) {2 + 2},
pull_profiles = function(dates_range) {3 + 3}
))
aws_buffer <- AwsBuffer$new()
#-- 1.1 for now, from Rds file
aws_buffer$raw_dt <- readRDS(config$data_file)
#-- 1.2 trim to logged and migrated
aws_buffer$migrated_dt <- aws_buffer$raw_dt[user_logged == "production : DE : logged in" & migrated =="true", ]
#-- 1.3 subset of columns
aws_buffer$time_dt <- aws_buffer$migrated_dt[, .(user_id, session_id, timestamp)]
#-- 1.3 enrich sessions; we do it for the whole dataset, which might look redundatnt, but we do that only once, and will not recalculate each time a new cohort is selected
enrich_sessions(aws_buffer)
#-- 2. run modules
mod_cohort_server("cohort_ui_1", aws_buffer)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.