Skip to content

Commit

Permalink
build: targets to save feedback surveys
Browse files Browse the repository at this point in the history
Closes #25
  • Loading branch information
lwjohnst86 committed Apr 21, 2024
1 parent deebb6d commit 71169c8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/save-to-file.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ save_feedback_to_csv <- function(data, columns) {
dplyr::ungroup() |>
dplyr::select(data, path)

purrr::walk2(
purrr::map2_chr(
data_to_save$data,
fs::path_ext_set(data_to_save$path, "csv"),
save_to_csv
)
) |>
fs::path_rel(usethis::proj_path(".")) |>
as.character()
}
36 changes: 36 additions & 0 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,41 @@ list(
name = feedback_survey_sessions,
command = extract_feedback_sessions(feedback_survey),
pattern = map(feedback_survey)
),

# Save to file -----------------------------------------------------------
tar_target(
name = combined_feedback,
command = list(
list(
data = feedback_survey_overall |>
dplyr::mutate(type = "feedback-overall"),
columns = c("course_id", "course_date", "type")
),
list(
data = feedback_survey_quantitative |>
dplyr::mutate(type = "feedback-quantitative"),
columns = c("course_id", "course_date", "type")
),
list(
data = feedback_survey_sessions |>
dplyr::mutate(type = "feedback-sessions"),
columns = c("course_id", "course_date", "type", "date")
),
list(
data = precourse_feedback |>
dplyr::mutate(type = "feedback-precourse"),
columns = c("course_id", "course_date", "type")
)
)
),
tar_target(
name = saved_feedback_sessions_paths,
command = combined_feedback |>
purrr::map(\(feedback) save_feedback_to_csv(feedback$data, feedback$columns)) |>
unlist(),
pattern = map(combined_feedback),
iteration = "list",
format = "file"
)
)

0 comments on commit 71169c8

Please sign in to comment.