Skip to content

Commit

Permalink
fixed db warnings and other minor annoyances
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Oct 5, 2023
1 parent d898d56 commit d17ba1e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 27 deletions.
9 changes: 4 additions & 5 deletions R/cohort-diagnostics-cohort-overlap.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,17 @@ cohortOverlapView <- function(id) {
id = ns("overlapPlotContainer"),
plotly::plotlyOutput(ns("overlapPlot"), width = "100%", height = "300px")
)
)
),

# complicated way of setting plot height based on number of rows and selection type
),
# complicated way of setting plot height based on number of rows and selection type
# Note that this code is only used because renderUI/ uiOutput didn't seem to update with plotly
shiny::tags$script(sprintf("
Shiny.addCustomMessageHandler('%s', function(height) {
let plotSpace = document.getElementById('%s');
plotSpace.querySelector('.svg-container').style.height = height;
plotSpace.querySelector('.js-plotly-plot').style.height = height;
});
", ns("overlapPlotHeight"), ns("overlapPlotContainer"))),
", ns("overlapPlotHeight"), ns("overlapPlotContainer")))
),
shiny::tabPanel(
title = "Table",
shiny::fluidRow(
Expand Down
2 changes: 1 addition & 1 deletion R/cohort-diagnostics-main-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ cohortDiagnosticsView <- function(id = "DiagnosticsExplorer") {
)
)
),
shiny::fluidPage(
shiny::tagList(
shiny::conditionalPanel(
ns = ns,
condition = "input.tabs == 'cohortDefinitions'",
Expand Down
18 changes: 1 addition & 17 deletions R/cohort-diagnostics-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,8 @@ createCdDatabaseDataSource <- function(
return(dataSource)
}

# SO much of the app requires this table in memory - it would be much better to re-write queries to not need it!
getDatabaseTable <- function(dataSource) {

# hot fix
if(tolower(paste0(dataSource$databaseTablePrefix, dataSource$databaseTable)) == 'database_meta_data'){
databaseTable <- dataSource$connectionHandler$queryDb(
"SELECT *, cdm_source_abbreviation as database_name FROM @schema.@table_name",
schema = dataSource$schema,
table_name = paste0(dataSource$databaseTablePrefix, dataSource$databaseTable)
) # end hot fix
} else{
databaseTable <- loadResultsTable(
dataSource = dataSource,
tableName = paste0(dataSource$databaseTablePrefix, dataSource$databaseTable),
required = TRUE
)
}

databaseTable <- loadResultsTable(dataSource, dataSource$databaseTable, required = TRUE)
if (nrow(databaseTable) > 0 &
"vocabularyVersion" %in% colnames(databaseTable)) {
databaseTable <- databaseTable %>%
Expand Down
Binary file modified tests/resources/cdDatabase/databaseFile.sqlite
Binary file not shown.
4 changes: 0 additions & 4 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ resultDatabaseSettingsCohortDiag <- list(
dbms = 'sqlite',
cdTablePrefix = '',
schema = "main",
cgTablePrefix = '',
cgTable = "cohort",
databaseTablePrefix = '',
databaseTable = "database",
vocabularyDatabaseSchema = "main"
)

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-cohort-diagnostics-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ shiny::testServer(cohortDiagnosticsServer, args = list(
resultDatabaseSettings = resultDatabaseSettingsCohortDiag,
dataSource = dataSourceCd
), {

## input tests will go here
session$setInputs(
tabs = "cohortCounts",
Expand Down

0 comments on commit d17ba1e

Please sign in to comment.