Skip to content

Commit

Permalink
include implementation of extracting activity notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ha0ye committed Jan 19, 2024
1 parent 72083f8 commit 41e485c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 23 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.2
Version: 0.9.3
Authors@R:
person("Hao", "Ye", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-8630-1458"))
Expand Down
23 changes: 17 additions & 6 deletions R/interface_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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)
}
8 changes: 7 additions & 1 deletion R/notifications.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions R/processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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)
}
Expand All @@ -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" &&
Expand All @@ -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" &&
Expand All @@ -172,15 +172,15 @@ 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 {
# if any other discrepancy
# 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)
}
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41e485c

Please sign in to comment.