From 5d149561a3d5dde9ec9a06ef5e542a55dffa7947 Mon Sep 17 00:00:00 2001 From: Hao Ye Date: Fri, 9 Feb 2024 12:08:06 -0500 Subject: [PATCH] update logic update notification --- DESCRIPTION | 2 +- R/logging.R | 13 +++++++++++++ R/processing.R | 42 ++++++++++++++-------------------------- man/log_status_update.Rd | 2 +- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 95d752a..3626cc9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gdrive.automation Title: Sync and Automate C4R Unit Progress -Version: 0.9.4 +Version: 0.9.5 Authors@R: person("Hao", "Ye", , "haoye@seas.upenn.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8630-1458")) diff --git a/R/logging.R b/R/logging.R index f89b7be..e02d99d 100644 --- a/R/logging.R +++ b/R/logging.R @@ -24,6 +24,19 @@ log_action <- function(action = "", url = "", type = "INFO", loop_num = NULL) invisible() } +#' generate status update content +#' +#' @param status_msg formatted status msg +#' @param tracker_url URL of a google sheet (Unit Tracker) +#' +#' @return NULL +log_status_update <- function(status_msg, tracker_url) +{ + log_action(paste0("Updating status: {\n", status_msg, "}"), + url = tracker_url, + "ACTION TAKEN") +} + #' Record a todo in the log #' #' All changes to files in the C4R googledrive that are performed by this diff --git a/R/processing.R b/R/processing.R index 69515b4..1b26a13 100644 --- a/R/processing.R +++ b/R/processing.R @@ -100,7 +100,8 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, tracker_status <- tracker_dat[i, "Status"] phase <- match(roadmap_dat[i, "Phase"], getOption("gdrv_auto_env.phase_names")) status_msg <- format_status_msg(roadmap_dat[i,]) - roadmap_task <- roadmap_dat[i, "Task"] + task <- roadmap_dat[i, "Task"] + signoff_by <- roadmap_dat$`Signoff by`[i] unit_id <- roadmap_dat[i, "unit_id"] if (roadmap_status == "Submitted" && @@ -147,49 +148,36 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, notify(item_name = paste("New Submission:", unit_id, "-", roadmap_task), item_body = status_msg, - notify_text = format_notification_msg("Submitted: ", roadmap_dat[i, ]), + notify_text = format_notification_msg("CENTER to review: ", roadmap_dat[i, ]), to = "Hao Ye") + } else if (roadmap_status == "Under review") { + # if roadmap is under review + log_status_update(status_msg, tracker_url) + tracker_dat$Status[i] <- roadmap_status - } else if (roadmap_status == "Approved" && - roadmap_dat$`Signoff by`[i] != "CENTER") { - # if roadmap is approved and signoff is by METER or NIH + notify(item_name = paste("Now in Review:", unit_id, "-", roadmap_task), + item_body = status_msg, + notify_text = format_notification_msg(paste(signoff_by, "reviewing: "), roadmap_dat[i, ]), + to = "Hao Ye") + } else if (roadmap_status == "Approved") { + # if roadmap is approved # take action for approval log_status_update(status_msg, tracker_url) tracker_dat$Status[i] <- roadmap_status notify(item_name = paste("New Approval:", unit_id, "-", roadmap_task), item_body = status_msg, - notify_text = format_notification_msg("Approved: ", roadmap_dat[i, ]), + notify_text = format_notification_msg(paste(signoff_by, "Approved: "), roadmap_dat[i, ]), to = "Hao Ye") - } else if (tracker_status == "Approved" && - roadmap_status != "Approved") { - # if tracker is approved and roadmap is not approved - # log action needed (update roadmap) - - stage_todo(paste0("Approve: {\n", status_msg, "}"), - url = roadmap_url) } else { # if any other discrepancy # log action needed - stage_todo(paste0("Unknown Status Difference: {\n", status_msg, "}"), + stage_todo(paste0("Unhandled Status Difference: {\n", status_msg, "}"), url = roadmap_url) } } tracker_dat } - -#' generate status update content -#' -#' @param status_msg formatted status msg -#' @param tracker_url URL of a google sheet (Unit Tracker) -#' -#' @return -log_status_update <- function(status_msg, tracker_url) -{ - log_action(paste0("Updating status: {\n", status_msg, "}"), - url = tracker_url, - "ACTION TAKEN") -} diff --git a/man/log_status_update.Rd b/man/log_status_update.Rd index b0cb1b1..d0a6641 100644 --- a/man/log_status_update.Rd +++ b/man/log_status_update.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processing.R +% Please edit documentation in R/logging.R \name{log_status_update} \alias{log_status_update} \title{generate status update content}