Skip to content

Commit

Permalink
update logic
Browse files Browse the repository at this point in the history
update notification
  • Loading branch information
ha0ye committed Feb 9, 2024
1 parent ce43c93 commit 5d14956
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-8630-1458"))
Expand Down
13 changes: 13 additions & 0 deletions R/logging.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 15 additions & 27 deletions R/processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion man/log_status_update.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d14956

Please sign in to comment.