we have created a Shiny App which is deployed on shinyapp.io. we are trying to reload the data on shinyapp.io in every 1 hour by using invalidateLater but it is not working when the application is closed/browser closed. we have heard about cronR but unable to use it through windows system(deploying the app from windows to shinyapp.io). cronR package is not being installed while deploying on shinyapp.io
In below code, We are trying to ping the database, and checks last ETL updated date with last data stored date if the time is greater then last data stored time then it will call the data_refresshing() function and it will reload the app.
observe({
invalidateLater(300000, session = session)
myRedshift <- src_postgres('dfdbwh',
host = 'xxxxxxxxxxxxxxxxxxxxxxx',
port = 1234,
user = "xxxxxxxx",
password = "xxxxxxxxxx")
data <- tbl(myRedshift, "MAX_ETLINCR_DATE_V")
t <- data %>% select(maxdate)
temp <- as.data.table(t)
last_ETL_updated_date_time <- temp$maxdate
last_updated_date_time <- readRDS("last_updated_date_time.rds")
if(last_updated_date_time < last_ETL_updated_date_time)
{
data_refreshing()
js$reload()
}
if(file.exists("Trigger_time.rds") == FALSE)
{
Trigger_time <- c(Trigger_time,paste0(now(tz="Asia/Kolkata")))
saveRDS(Trigger_time,file = "Trigger_time.rds")
}
else
{
Trigger_time <- readRDS("Trigger_time.rds")
Trigger_time <- c(Trigger_time,paste0(now(tz="Asia/Kolkata")))
saveRDS(Trigger_time,file = "Trigger_time.rds")
}
})