R/main.R

Defines functions download_all_and_get_table download_all_and_output_to_csv

Documented in download_all_and_get_table download_all_and_output_to_csv

#' Get submissions and save to file
#'
#' Download all submissions, process into a single table, and output
#' the table to a csv file. This will also output all forms to the
#' same output directory.
#'
#' @export
#' @param syn Synapse login object
#' @param state_filter The filter that is desired to gather submissions by.
#' @param group The groupID.
#' @param output_dir The directory to output the submissions and csv file to.
download_all_and_output_to_csv <- function(syn, group, output_dir,
                                           state_filter = "SUBMITTED_WAITING_FOR_REVIEW") { # nolint
  download_all_submissions_local(
    syn = syn,
    state_filter = state_filter,
    group = group,
    output_dir = output_dir
  )
  data <- convert_all_forms_to_table(directory = output_dir)
  output_submission_csv(data = data, output_dir = output_dir)
}

#' Get all submissions as single table
#'
#' Download all submissions, process into a single table. The column
#' names will be generated by [convert_all_forms_to_table()], which
#' currently is the formDataId given that it is unique.
#'
#' @export
#' @param syn Synapse login object
#' @param state_filter The filter that is desired to gather submissions by.
#' @param group The groupID.
download_all_and_get_table <- function(syn, group,
                                       state_filter = "SUBMITTED_WAITING_FOR_REVIEW") { # nolint
  file_list <- download_all_submissions_temp(
    syn = syn,
    state_filter = state_filter,
    group = group
  )
  data <- convert_all_forms_to_table(file_list = file_list)
  data
}
Sage-Bionetworks/synapseforms documentation built on June 16, 2020, 8:35 a.m.