Skip to content

Commit

Permalink
fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Mar 1, 2024
1 parent cf1868f commit 4b6916d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* link preview cards are automatically added to posts (can be turned off)
* unified approach to parsing actor data
* new function: skeet_shot (high quality screenshots of skeets)
* properly paginate get_user_info (#14)

# atrrr 0.0.2

Expand Down
21 changes: 13 additions & 8 deletions R/actors.r
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ get_user_info <- function(actor,
parse = TRUE,
.token = NULL) {

res <- do.call(
what = app_bsky_actor_get_profiles,
args = list(
actor,
.token = .token,
.return = "json"
)) |>
purrr::pluck("profiles")
actor_l <- split(actor, ceiling(seq_along(actor) / 25L))

res <- list()
for (actor_i in actor_l) {
res <- append(res, do.call(
what = app_bsky_actor_get_profiles,
args = list(
actor_i,
.token = .token,
.return = "json"
)) |>
purrr::pluck("profiles"))
}

if (parse) {
res <- parse_actors(res)
Expand Down
9 changes: 8 additions & 1 deletion tests/testthat/test-actors.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ test_that("search actors", {
expect_gte(nrow(search_user("JBGruber")), 1L)
})

test_that("use info", {
test_that("user info", {
expect_type(get_user_info("benguinaudeau.bsky.social", parse = FALSE), "list")
expect_s3_class(get_user_info("jbgruber.bsky.social"), "tbl_df")
expect_gte(nrow(get_user_info("favstats.bsky.social")), 1L)
})

test_that("user info pagination", {
actors <- rep(c("jbgruber.bsky.social",
"benguinaudeau.bsky.social",
"favstats.bsky.social"), 25)
expect_equal(nrow(get_user_info(actor = actors)), 75L)
})

0 comments on commit 4b6916d

Please sign in to comment.