diff --git a/DESCRIPTION b/DESCRIPTION index 9d202d8..4800ff8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gdrive.automation Title: Sync and Automate C4R Unit Progress -Version: 0.9.2 +Version: 0.9.3 Authors@R: person("Hao", "Ye", , "haoye@seas.upenn.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8630-1458")) diff --git a/R/interface_docs.R b/R/interface_docs.R index 4578127..fe5e41d 100644 --- a/R/interface_docs.R +++ b/R/interface_docs.R @@ -12,7 +12,7 @@ read_roadmap_statuses <- function(roadmap_url, dl_path = tempfile(fileext = ".do ## read in docx roadmap <- officer::read_docx(dl_path) - content <- officer::docx_summary(roadmap) + content <- officer::docx_summary(roadmap, preserve = TRUE) # find title title <- extract_roadmap_title(content) @@ -114,7 +114,7 @@ extract_roadmap_statuses <- function(content) ## setup loop statuses_df <- data.frame(phase = numeric(), mini_unit = numeric(), task = character(), signoff = character(), - status = character()) + status = character(), notes = character()) prev_phase <- 0 curr_mini_unit <- NA @@ -123,7 +123,7 @@ extract_roadmap_statuses <- function(content) # identify phase # identify parse group # perform parsing of statuses - # identify appopriate parsing + # identify appropriate parsing for (curr_signoff_doc_index in signoff_labels$doc_index) { # find next table after "sign off" label @@ -158,6 +158,15 @@ extract_roadmap_statuses <- function(content) # perform parsing of statuses status_format <- subset(parsing_dat, phase == curr_phase & parse_group == parse_grp_idx) result <- parse_statuses(curr_statuses$text, status_format) + + # if activity phase, find activity description box + if (curr_phase == getOption("gdrv_auto_env.statuses.activity_phase")) + { + prev_tables <- subset(content, + content_type %in% "table cell" & + doc_index < curr_statuses$doc_index) + result$notes <- tail(prev_tables, 1)$text + } result$phase <- curr_phase result$mini_unit <- curr_mini_unit statuses_df <- rbind(statuses_df, result) @@ -190,7 +199,7 @@ format_statuses <- function(statuses, title, mini_unit_names) if (num_missing_mini_units > 0) { d <- subset(statuses, phase == activity_phase & mini_unit == 1) %>% - dplyr::mutate(status = "Not started") + dplyr::mutate(status = "Not started", notes = NA) to_add <- do.call("rbind", replicate(num_missing_mini_units, d, simplify = FALSE)) to_add$mini_unit <- rep(seq(to = num_expected_mini_units, length.out = num_missing_mini_units), @@ -211,7 +220,8 @@ format_statuses <- function(statuses, title, mini_unit_names) Phase = phase, Task = task, `Signoff by` = signoff, - Status = status) + Status = status, + notes) } #' Extract Statuses from a Given String @@ -225,5 +235,6 @@ parse_statuses <- function(string, status_format) { data.frame(task = status_format$task, signoff = status_format$signoff, - status = stringr::str_extract(string, status_format$pattern, group = 1)) + status = stringr::str_extract(string, status_format$pattern, group = 1), + notes = NA) } diff --git a/R/notifications.R b/R/notifications.R index 949d9c6..86bb16d 100644 --- a/R/notifications.R +++ b/R/notifications.R @@ -11,12 +11,18 @@ format_status_msg <- function(status_row, sep = "\n") { stopifnot(NROW(status_row) == 1) - paste0("unit: ", status_row$Unit, sep, + result <- paste0("unit: ", status_row$Unit, sep, "mini-unit: ", status_row$`Mini-Unit`, sep, "phase: ", status_row$Phase, sep, "task: ", status_row$Task, sep, "signoff by: ", status_row$`Signoff by`, sep, "status: ", status_row$Status, sep) + if (!is.na(status_row$notes)) + { + result <- paste0(result, + "notes: ", status_row$notes, sep) + } + result } #' @rdname msg diff --git a/R/processing.R b/R/processing.R index 555259e..4a04b1e 100644 --- a/R/processing.R +++ b/R/processing.R @@ -106,8 +106,8 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, if (roadmap_task == "Activity Description" || roadmap_task == "Activity Demonstration") { - ## notify Hao for METER to review Activtiy Description OR Activity Demonstration - status_msg <- format_status_msg(tracker_dat[i,]) + ## notify Hao for METER to review Activity Description OR Activity Demonstration + status_msg <- format_status_msg(roadmap_dat[i,]) log_action(paste0("Updating status: {\n", status_msg, "}"), url = tracker_url, "ACTION TAKEN") @@ -116,7 +116,7 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, to = "Hao Ye") } else if (roadmap_task == "Activity Tech Specs") { ## notify Thomas to review Activity Tech Spec - status_msg <- format_status_msg(tracker_dat[i,]) + status_msg <- format_status_msg(roadmap_dat[i,]) log_action(paste0("Updating status: {\n", status_msg, "}"), url = tracker_url, "ACTION TAKEN") @@ -125,7 +125,7 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, to = "Thomas McDonald") } else if (roadmap_task == "Prototype") { ## notify Hao and Thomas to review Prototype - status_msg <- format_status_msg(tracker_dat[i,]) + status_msg <- format_status_msg(roadmap_dat[i,]) log_action(paste0("Updating status: {\n", status_msg, "}"), url = tracker_url, "ACTION TAKEN") @@ -134,7 +134,7 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, to = c("Thomas McDonald", "Hao Ye")) } else { stage_todo(paste0("Unknown Status Difference: {\n", - format_status_msg(tracker_dat[i,]), + format_status_msg(roadmap_dat[i,]), "}"), url = roadmap_url) } @@ -144,12 +144,12 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, # take action for submission tracker_dat$Status[i] <- roadmap_status - status_msg <- format_status_msg(tracker_dat[i,]) + status_msg <- format_status_msg(roadmap_dat[i,]) log_action(paste0("Updating status: {\n", status_msg, "}"), url = tracker_url, "ACTION TAKEN") notify(msg = status_msg, - notify_text = format_notification_msg("Submitted: ", tracker_dat[i, ]), + notify_text = format_notification_msg("Submitted: ", roadmap_dat[i, ]), to = "Hao Ye") } else if (roadmap_status == "Approved" && @@ -158,12 +158,12 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, # take action for approval tracker_dat$Status[i] <- roadmap_status - status_msg <- format_status_msg(tracker_dat[i,]) + status_msg <- format_status_msg(roadmap_dat[i,]) log_action(paste0("Updating status: {\n", status_msg, "}"), url = tracker_url, "ACTION TAKEN") notify(msg = status_msg, - notify_text = format_notification_msg("Approved: ", tracker_dat[i, ]), + notify_text = format_notification_msg("Approved: ", roadmap_dat[i, ]), to = "Hao Ye") } else if (tracker_status == "Approved" && @@ -172,7 +172,7 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, # log action needed (update roadmap) stage_todo(paste0("Approve: {\n", - format_status_msg(tracker_dat[i,]), + format_status_msg(roadmap_dat[i,]), "}"), url = roadmap_url) } else { @@ -180,7 +180,7 @@ handle_diff_statuses <- function(roadmap_dat, roadmap_url, # log action needed stage_todo(paste0("Unknown Status Difference: {\n", - format_status_msg(tracker_dat[i,]), + format_status_msg(roadmap_dat[i,]), "}"), url = roadmap_url) } diff --git a/README.Rmd b/README.Rmd index 09472ec..862874d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -51,8 +51,8 @@ There are 4 states for the status, which generally progresses from: “Not started” -\> “Submitted” -\> “Under review” -\> “Approved” -The below documentation clarifies how to resolve situations where the -status for a particular item is different in the roadmap vs. the +The below describes the general procedure for resolving situations where the +status for a particular item is different in the roadmap vs. the tracker. ### Case 0. Identical Status diff --git a/README.md b/README.md index d6111e9..5b7f18d 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ There are 4 states for the status, which generally progresses from: “Not started” -\> “Submitted” -\> “Under review” -\> “Approved” -The below documentation clarifies how to resolve situations where the -status for a particular item is different in the roadmap vs. the +The below describes the general procedure for resolving situations where +the status for a particular item is different in the roadmap vs. the tracker. ### Case 0. Identical Status