Skip to content

Commit

Permalink
Patch/reminder (#72)
Browse files Browse the repository at this point in the history
* Fix

* Correct testing notes in README

* Update .gitignore
  • Loading branch information
anngvu authored Sep 5, 2023
1 parent 1531ec0 commit f57d32a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.log
envfile-*
2 changes: 1 addition & 1 deletion monitor_annotations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DIGEST_SUBSCRIBERS=1111111;2222222

#### With Docker image

- Build the image with e.g. `docker build -t ghcr.io/nfosi/jobs-monitor-annotations .` (or pull current/pre-build image if available)
- Build the image with e.g. `docker build --no-cache -t ghcr.io/nf-osi/jobs-monitor-annotations .` (or pull current/pre-build image if available)
- Create an envfile `envfile-monitor-anno` as above and run `docker run --env-file envfile-monitor-anno ghcr.io/nf-osi/jobs-monitor-annotations`

#### Unit tests
Expand Down
17 changes: 12 additions & 5 deletions monitor_annotations/monitor_annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ library(httr)

# Config -----------------------------------------------------------------------#

# Run profile --------#

# Check whether running as DEV, TEST or PROD, with DEV being default and catch-all. Behavior for:
# PROD = Send emails to actual users
# TEST = Send emails to nf-osi-service (3421893)
Expand All @@ -22,13 +24,18 @@ secrets <- jsonlite::fromJSON(Sys.getenv("SCHEDULED_JOB_SECRETS"))
syn_login(authtoken = secrets[["SYNAPSE_AUTH_TOKEN"]])

DCC_USER <- Sys.getenv("DCC_USER")
TEST_USER <- as.character(Sys.getenv("TEST_USER"))

if(PROFILE == "TEST" && TEST_USER == "") error("For PROFILE=TEST you must set TEST_USER=xxx")
if(PROFILE == "TEST") {
TEST_USER <- as.character(Sys.getenv("TEST_USER"))
if(TEST_USER == "") error("For PROFILE=TEST you must set TEST_USER=xxx")
} else {
TEST_USER <- NULL
}

DRY_RUN <- if(PROFILE == "DEV") TRUE else FALSE

# Reference tables
# Reference tables --------#

study_tab_id <- 'syn16787123'
fileview_tab_id <- 'syn16858331'
no_email_list <- 'syn51907919'
Expand All @@ -49,13 +56,13 @@ try({
withCallingHandlers(
{
todo <- make_active_study_reminder_list(study_tab_id, fileview_tab_id)
if(DRY_RUN) sink("messages.log", append = TRUE, split = TRUE)
# if(DRY_RUN) sink("messages.log", append = TRUE, split = TRUE)
send_message_list(todo,
dcc_user = DCC_USER,
test_user = TEST_USER,
no_email_list_users = no_email_list_users,
dry_run = DRY_RUN)
sink()
# sink()

},
warning = function(w) handleWarning(w, "main"),
Expand Down

0 comments on commit f57d32a

Please sign in to comment.