瀏覽代碼

rework pipeline to locally store complete report as raw text

main
Garrick Aden-Buie 2 年之前
父節點
當前提交
261a6f5837
沒有發現已知的金鑰在資料庫的簽署中
共有 5 個檔案被更改,包括 17073 行新增96 行删除
  1. +4
    -2
      DESCRIPTION
  2. +24
    -0
      R/get.R
  3. +1
    -1
      R/utils-delay.R
  4. +5
    -4
      _targets.R
  5. +17039
    -89
      _targets/meta/meta

+ 4
- 2
DESCRIPTION 查看文件

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

+ 24
- 0
R/get.R 查看文件



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)
}

+ 1
- 1
R/utils-delay.R 查看文件

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))
} }
} }

+ 5
- 4
_targets.R 查看文件

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"
) )
) )

+ 17039
- 89
_targets/meta/meta
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存