Hi,
I am working on a shiny dashboard application with the following code:
server.R
function(input, output, session) {
itm_data <- reactive({
itm_cash_count <- itm_transaction.db %>%
group_by(atm_id) %>%
filter(as.Date(atm_datetime) == "2023-09-22" & !transaction_type %in% c("PinAuthentication", "CheckDeposit", "CheckCashing")) %>%
select(atm_id, atm_datetime, transaction_id, transaction_type, host_type, identification_type, amount_dispensed, amount_deposited,
denomination_1_after, denomination_5_after, denomination_20_after, denomination_100_after, atm_cash_after) %>%
collect()
itm_cash_count
})
itm_location_id <- itm_locations %>%
filter(location == "Main") %>%
pull(id)
output$table <- render_gt({
itm_data() |>
filter(atm_id %in% c(54321101, 54321008, 54321103)) |>
select(atm_id, denomination_1_after, denomination_5_after, denomination_20_after, denomination_100_after) |>
rename('ATM ID' = atm_id,
'$1 Bills' = denomination_1_after,
'$5 Bills' = denomination_5_after,
'$20 Bills' = denomination_20_after,
'$100 Bills' = denomination_100_after) |>
gt() |>
cols_label_with(columns = everything(), fn = toupper) |>
sub_missing() |>
opt_interactive(use_compact_mode = TRUE)
})
}
ui.R
dashboardPage(
dark = NULL,
fullscreen = TRUE,
help = NULL,
scrollToTop = TRUE,
title = "ITM",
preloader = list(html = tagList(spin_1(), "Loading ..."), color = "#3c8dbc"),
header = dashboardHeader(
title = tags$div("ITM Dashboard", style="padding:5px"),
controlbarIcon = shiny::icon("bars")
),
sidebar = dashboardSidebar(
disable = TRUE
),
controlbar = dashboardControlbar(
div(
tags$h5("Settings", style="text-align:center; padding-bottom:20px"),
dateInput("date", "Select a date:", value = Sys.Date()),
sliderInput("intervall", "Select Intervall:",
min = 30,
max = 1440,
value = 60),
style="padding-left:20px; padding-right: 20px; padding-top:20px;"
)
),
footer = dashboardFooter(
left = "ⓒ 2023",
right = "v. 0.0.1"
),
body = dashboardBody(
fluidRow(
column(width = 12,
box(title = "Transaction Details",
id = "transaction_details",
collapsible = TRUE,
closable = FALSE,
maximizable = TRUE,
width = NULL,
gt_output(outputId = "table")
)
)
),
)
)
global.R
# Load libraries
## Core functions
library(shiny) # Core function
library(bs4Dash) # Core dashboard theme
## Data functions
library(readr) # Rear csv
library(odbc) # DB connector
library(pool) # Pooling DB connector
library(dplyr) # Data wrangling
library(dbplyr) # DB addition to dplyr
library(tidyr) # Data manipulation
library(lubridate) # Time manipulation
## Additional modules for output
library(waiter) # Adding spinners to loading page
library(gt) # Adding table creation support
# Open connection to Pond
pool <- dbPool(
drv = odbc::odbc(),
driver = "PostgreSQL",
server = "AWS_SERVER_NAME",
Database = "ponds",
UID = Sys.getenv("terra_uid"),
PWD = Sys.getenv("terra_pwd")
)
itm_transaction.db <- pool |>
dplyr::tbl(dbplyr::in_schema("prod", "fct_itm_transactions"))
itm_locations <- read_csv(file = "data/latlong.csv",
col_types = list(
`id` = col_integer(),
`lane` = col_character()
),
col_names = c("id", "location", "lane", "address", "latitude", "longitude"),
skip = 1)
This setting works on my lokal computer (Mac M1 current OS) without any problems. If I deploy it on a connect server that is running on a Linux server in a docker container (R and connect are both latest), however, it does not work, neither does it on workbench on a Linux server also running in a docker container.
the result on the connect server is, that the table is empty. If I replace %in%
in the output$table
commend in server.R, to atm_id == 54321103
it works....
Does anyone has an idea why it doesn't work? It honestly drives me crazy not finding the mistake... :-/
Thanks for your help.