Skip to content

Commit 8c249cf

Browse files
committed
Fix list_party_volumes(); fix typo in list_party_sponsors().
1 parent 4ab264e commit 8c249cf

File tree

3 files changed

+57
-22
lines changed

3 files changed

+57
-22
lines changed

R/list_party_sponsors.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ list_party_sponsors <- function(party_id = 6,
3737
rq <- make_default_request()
3838
}
3939

40-
party_info <- get_party_by_id(party_id, vb, rq)
41-
4240
if (vb)
4341
message(paste0("Getting sponsors for party ", party_id, "."))
4442

R/list_party_volumes.R

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,67 @@ list_party_volumes <- function(party_id = 6,
2929
if (is.null(rq)) {
3030
if (vb) {
3131
message("NULL request object. Will generate default.")
32-
message("\nNot logged in. Only public information will be returned.")
32+
message("\nNot logged in. Only public information will be returned.")
3333
}
3434
rq <- databraryr::make_default_request()
3535
}
3636

37-
g <- databraryr::get_party_by_id(party_id, vb, rq)
37+
vol_id <- NULL
3838

39-
if (!is.null(g)) {
39+
if (vb)
40+
message(paste0("Retrieving data for party ", party_id, "."))
41+
party_info <- databraryr::get_party_by_id(party_id, vb, rq)
42+
43+
if (!is.null(party_info)) {
4044
if (vb)
41-
message(paste0("Retrieving data for party ", party_id, "."))
42-
purrr::map(
43-
g$access,
44-
.f = function(x) {
45-
as.data.frame(x[[3]])
46-
}
47-
) %>% purrr::list_rbind() %>%
48-
dplyr::mutate(party_id = party_id,
49-
prename = g$prename,
50-
sortname = g$sortname,
51-
affiliation = g$affiliation)
45+
message(paste0("Info retrieved. Filtering."))
46+
purrr::map(party_info$access, extract_vol_fr_party) %>%
47+
purrr::list_rbind() %>%
48+
dplyr::mutate(
49+
party_id = party_id,
50+
party_prename = party_info$prename,
51+
party_sortname = party_info$sortname,
52+
party_affiliation = party_info$affiliation
53+
) %>%
54+
dplyr::arrange(vol_id)
5255
} else {
5356
if (vb)
5457
message(paste0("No data for party ", party_id, "."))
55-
g
58+
party_info
5659
}
57-
#TODO: Reformat output
5860
}
61+
62+
#---------------------------------------------------------------------------
63+
# This is a private, not exported,
64+
# helper function for list_party_volumes()
65+
#
66+
extract_vol_fr_party <- function(p_info) {
67+
assertthat::assert_that(is.list(p_info))
68+
69+
this_vol <- p_info$volume
70+
71+
vol_names <- names(this_vol)
72+
assertthat::assert_that("id" %in% vol_names)
73+
assertthat::assert_that("name" %in% vol_names)
74+
assertthat::assert_that("body" %in% vol_names)
75+
assertthat::assert_that("creation" %in% vol_names)
76+
assertthat::assert_that("permission" %in% vol_names)
77+
78+
vol_id <- this_vol$id
79+
vol_name <- this_vol$name
80+
vol_body <- this_vol$body
81+
if (!("alias" %in% vol_names)) {
82+
vol_alias = NA
83+
} else {
84+
vol_alias <- this_vol$alias
85+
}
86+
vol_creation <- this_vol$creation
87+
vol_permission <- this_vol$permission
88+
89+
tibble::tibble(vol_id,
90+
vol_name,
91+
vol_body,
92+
vol_alias,
93+
vol_creation,
94+
vol_permission)
95+
}

vignettes/authorized-users.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,27 @@ To do this, use the `store` and `overwrite` parameters in `login_db()`:
8080

8181
```{r, eval=FALSE}
8282
databraryr::login_db(email = "<YOUR_EMAIL@PROVIDER.COM>", store = TRUE,
83-
overwrite = TRUE, rq = lrq)
83+
overwrite = TRUE, rq = drq)
8484
```
8585

8686
This overwrites and securely stores your credentials, so that the next time you log in, you need only use this command:
8787

8888
```{r, eval=FALSE}
89-
databraryr::login_db(email = "<YOUR_EMAIL@PROVIDER.COM>", store = TRUE, rq = lrq)
89+
databraryr::login_db(email = "<YOUR_EMAIL@PROVIDER.COM>", store = TRUE, rq = drq)
9090
```
9191

9292
or if you've stored your email as an environment variable:
9393

9494
```{r, eval=FALSE}
95-
databraryr::login_db(email = Sys.getenv("DATABRARY_LOGIN"), store = TRUE, rq = lrq)
95+
databraryr::login_db(email = Sys.getenv("DATABRARY_LOGIN"), store = TRUE, rq = drq)
9696
```
9797

9898
### Logging out
9999

100100
The package also has a log out command.
101101

102102
```{r eval=FALSE}
103-
databraryr::logout_db(rq = lrq)
103+
databraryr::logout_db(rq = drq)
104104
```
105105

106106
**NOTE**: Most `databraryr` functions have a verbose (`vb`) parameter. If you set this to `TRUE`, you will get more information about what's going on.

0 commit comments

Comments
 (0)