ctsit / rcc.billing

Automated, data-driven service billing implemented on REDCap Custodian
https://ctsit.github.io/rcc.billing/
Apache License 2.0
0 stars 3 forks source link

`delete_abandoned_projects.R` needs to test current sequestration state #255

Open pbchase opened 1 week ago

pbchase commented 1 week ago

delete_abandoned_projects.R needs to test the current sequestration state. As documented in issue #254, the test for sequestered_orphans is too simplistic at https://github.com/ctsit/rcc.billing/blob/4b94e38f6bacbea69e65cd7d66d6e70167624519/etl/delete_abandoned_projects.R#L37

That is a test for projects that were sequestered. The code should also test those projects are still sequestered.

You could fix that by adding this object

is_sequestered <- tbl(rc_conn, "redcap_projects") |>
  left_join(tbl(rc_conn, "redcap_entity_project_ownership"), by = c("project_id" = "pid")) |>
  filter(!is.na(completed_time) & sequestered == 1) |>
  select(project_id)|>
  collect() |>
  pull(project_id)

And using it to filter sequestered_orphans