I deployed a shiny app to our company's AWS server. It serves as an internal dashboard. I recently found some articles about how to make the charts and tables refresh dynamically from the database every x milliseconds. However, this causes plots to be re-rendered every x milliseconds regardless of whether it is necessary or not. Aside from making the DashBoard jittery, I'm somewhat worried about the resource drain it might represent when the DashBoard will be full (about 60-100 plots). Is there a way that one can make the charts refresh whenever the table in the database that is being called changes?
Suppose the following dataframe is in the database:
df = tibble(id = as.factor(c(1:10)),
value = c(sample(c(1:50), 10, replace = TRUE)),
variable = c(sample(c('blue','red','green'), 10, replace = TRUE)))
And the 'df' object now represents the pool connector to the database:
renderPlot{(
invalidateLater(10000)
my plot = df %>%
ggplot(aes(id, value, color = variable)) +
geom_point()
myplot
)}
This plot will basically be re-rendered every 10 seconds, which causes the entire plot to refresh. What I would like is to instead check the database every 10 seconds, and re-render the plot only if the database table being called has changed. Any ideas?