Skip to content

Commit a0c7357

Browse files
Merge pull request #164 from pbchase/no_deleted_projects_in_cred_db
Filter out deleted projects in scrape_user_api_tokens()
2 parents f9a5779 + 1acff21 commit a0c7357

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

R/credential_management.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ scrape_user_api_tokens <- function(conn, username_to_scrape = Sys.info()[["user"
4141
dplyr::tbl(conn, "redcap_projects") %>%
4242
dplyr::select(
4343
"project_id",
44-
"app_title"
44+
"app_title",
45+
"date_deleted"
4546
),
4647
by = "project_id"
4748
) %>%
4849
dplyr::collect() %>%
50+
# filter out deleted projects
51+
dplyr::filter(is.na(.data$date_deleted)) |>
52+
dplyr::select(-"date_deleted") |>
4953
# bind_rows used over rbind to avoid need to align column order
5054
dplyr::bind_rows(super_credentials) %>%
5155
dplyr::rename(
@@ -125,12 +129,9 @@ set_project_api_token <- function(conn, username, project_id) {
125129
DBI::dbExecute(conn, sql)
126130
}
127131

128-
129-
130132
save_credentials <- function(
131-
file_path,
132-
project_id = "0",
133-
token
134-
) {
133+
file_path,
134+
project_id = "0",
135+
token) {
135136

136137
}

0 commit comments

Comments
 (0)