Skip to content

Commit

Permalink
Merge pull request #1313 from bigomics/dev-log-report-downloads
Browse files Browse the repository at this point in the history
feat: log report downloads
  • Loading branch information
ivokwee authored Dec 24, 2024
2 parents 13b8138 + 58b769b commit 8ae4638
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/app/R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ shiny::addResourcePath("static", file.path(OPG, "components/app/R/www"))
## Initialize plot download logger
PLOT_DOWNLOAD_LOGGER <<- reactiveValues(log = list(), str = "")

## Initialize report download logger
REPORT_DOWNLOAD_LOGGER <<- reactiveValues(log = list(), str = "")

## Initialize translator
library(shiny.i18n)
DICTIONARY <- file.path(FILES, "translation.json")
Expand Down
1 change: 1 addition & 0 deletions components/app/R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ app_server <- function(input, output, session) {
session = session,
comment = nav_count.str,
comment2 = isolate(PLOT_DOWNLOAD_LOGGER$str),
comment3 = isolate(REPORT_DOWNLOAD_LOGGER$str),
num_datasets = num_pgxfiles,
ip = session$request$HTTP_X_REAL_IP
)
Expand Down
1 change: 1 addition & 0 deletions components/modules/AuthenticationModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ LoginCodeAuthenticationModule <- function(id,
updateTextInput(session, "login_password", value = "")

PLOT_DOWNLOAD_LOGGER <<- reactiveValues(log = list(), str = "")
REPORT_DOWNLOAD_LOGGER <<- reactiveValues(log = list(), str = "")

shiny::showModal(login_modal)
}
Expand Down
1 change: 1 addition & 0 deletions components/modules/DatasetReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ DatasetReportServer <- function(
setwd(cur_wd)
unlink(tmpdir)

record_report_download(input$report_type)
shinyalert::shinyalert(
title = "Yay! Your report is ready",
text = "We finished your report. Please check your downloads folder.",
Expand Down
16 changes: 16 additions & 0 deletions components/modules/ReportDownloadLogger.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
##
## This file is part of the Omics Playground project.
## Copyright (c) 2018-2024 BigOmics Analytics SA. All rights reserved.
##


record_report_download <- function(reportName) {
if (reportName %in% names(REPORT_DOWNLOAD_LOGGER$log)) {
REPORT_DOWNLOAD_LOGGER$log[[reportName]] <- REPORT_DOWNLOAD_LOGGER$log[[reportName]] + 1
} else {
REPORT_DOWNLOAD_LOGGER$log[[reportName]] <- 1
}
# Convert the log to a string format
REPORT_DOWNLOAD_LOGGERStr <- paste(names(REPORT_DOWNLOAD_LOGGER$log), REPORT_DOWNLOAD_LOGGER$log, sep = " = ", collapse = "; ")
REPORT_DOWNLOAD_LOGGER$str <- REPORT_DOWNLOAD_LOGGERStr # Update the log with the string representation
}
2 changes: 2 additions & 0 deletions components/modules/UserAccessControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pgx.record_access <- function(user,
action,
comment = "",
comment2 = "",
comment3 = "",
session = session,
num_datasets = "",
time = Sys.time(),
Expand Down Expand Up @@ -55,6 +56,7 @@ pgx.record_access <- function(user,
client.ip = remote_addr,
comment = comment,
comment2 = comment2,
comment3 = comment3,
num_datasets = num_datasets,
ip = ip
)
Expand Down

0 comments on commit 8ae4638

Please sign in to comment.