| RoxygenNote: 7.2.3 | RoxygenNote: 7.2.3 | ||||
| Depends: | Depends: | ||||
| dplyr, | dplyr, | ||||
| fs, | |||||
| glue, | glue, | ||||
| httr2, | httr2, | ||||
| readr, | readr, | ||||
| rlang | |||||
| rlang, | |||||
| targets | |||||
| Imports: | Imports: | ||||
| cli, | cli, | ||||
| crew, | crew, | ||||
| desc, | desc, | ||||
| targets, | |||||
| here, | |||||
| visNetwork | visNetwork |
| res | res | ||||
| } | } | ||||
| get_raw_report_all <- function(report_id) { | |||||
| delay() | |||||
| res <- | |||||
| req_report_detail(report_id, "all") |> | |||||
| req_perform() | |||||
| if (identical(res$body, raw(0))) return("") | |||||
| resp_body_string(res) | |||||
| } | |||||
| save_raw_report_all <- function(report_id, sboe_id) { | |||||
| res <- get_raw_report_all(report_id) | |||||
| dir <- here::here("data-raw", "reports", sboe_id) | |||||
| dir_create(dir) | |||||
| path <- path(dir, report_id, ext = "txt") | |||||
| brio::write_lines(res, path) | |||||
| invisible(path) | |||||
| } |
| delay <- function() { | delay <- function() { | ||||
| if (identical(Sys.getenv("IN_TARGETS"), "true")) { | if (identical(Sys.getenv("IN_TARGETS"), "true")) { | ||||
| Sys.sleep(runif(1, 0, 2)) | |||||
| Sys.sleep(runif(1, 0, 1)) | |||||
| } | } | ||||
| } | } |
| report_list, | report_list, | ||||
| doc_list |> | doc_list |> | ||||
| filter(!is.na(report_id)) |> | filter(!is.na(report_id)) |> | ||||
| filter(committee_name == "JOHN BELL COMM" | report_id == 188139) | |||||
| mutate(received = coalesce(received_data, received_image)) |> | |||||
| slice_max(received, by = report_id) | |||||
| ), | ), | ||||
| tar_target(report_list_report_id, report_list$report_id), | tar_target(report_list_report_id, report_list$report_id), | ||||
| tar_target(report_list_sboe_id, report_list$sboe_id), | tar_target(report_list_sboe_id, report_list$sboe_id), | ||||
| tar_target( | tar_target( | ||||
| receipts, | |||||
| get_report_section(report_list_report_id, "receipts", report_list_sboe_id), | |||||
| receipts_raw_path, | |||||
| save_raw_report_all(report_list_report_id, report_list_sboe_id), | |||||
| pattern = map(report_list_report_id, report_list_sboe_id), | pattern = map(report_list_report_id, report_list_sboe_id), | ||||
| format = "parquet" | |||||
| format = "file_fast" | |||||
| ) | ) | ||||
| ) | ) |