-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
rewrite PRO functions to query GraphQL
- Loading branch information
Showing
33 changed files
with
931 additions
and
11,345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ Imports: | |
purrr, | ||
gh, | ||
progress, | ||
tibble, | ||
rlang, | ||
rappdirs, | ||
glue, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
#' Get the discussion boards from a meetup group | ||
#' | ||
#' @template urlname | ||
#' @template verbose | ||
#' @return A tibble with the following columns: | ||
#' * id | ||
#' * name | ||
#' * description | ||
#' * created | ||
#' * updated | ||
#' * post_count | ||
#' * discussion_count | ||
#' * latest_reply_created | ||
#' * latest_reply_member_name | ||
#' * resource | ||
#' | ||
#' @references | ||
#' \url{https://www.meetup.com/meetup_api/docs/:urlname/boards/} | ||
#'@examples | ||
#' \dontrun{ | ||
#' urlname <- "rladies-nashville" | ||
#' meetup_boards <- get_boards(urlname = urlname) | ||
#'} | ||
#' @export | ||
get_boards <- function(urlname, | ||
verbose = meetupr_verbose()) { | ||
api_path <- paste0(urlname, "/boards") | ||
res <- .fetch_results(api_path = api_path, verbose = verbose) | ||
tibble::tibble( | ||
id = purrr::map_int(res, "id"), | ||
name = purrr::map_chr(res, "name"), | ||
description = purrr::map_chr(res, "description"), | ||
created = .date_helper(purrr::map_dbl(res, "created")), | ||
updated = .date_helper(purrr::map_dbl(res, "updated")), | ||
post_count = purrr::map_int(res, "post_count", .default = NA), | ||
discussion_count = purrr::map_int(res, "discussion_count", .default = NA), | ||
latest_reply_created = .date_helper(purrr::map_dbl(res, c("latest_reply", "created"), .default = NA)), | ||
latest_reply_member_name = purrr::map_chr(res, c("latest_reply", "member", "name"), .default = NA), | ||
resource = res | ||
) | ||
} | ||
#' #' Get the discussion boards from a meetup group | ||
#' #' | ||
#' #' @template urlname | ||
#' #' @template verbose | ||
#' #' @return A tibble with the following columns: | ||
#' #' * id | ||
#' #' * name | ||
#' #' * description | ||
#' #' * created | ||
#' #' * updated | ||
#' #' * post_count | ||
#' #' * discussion_count | ||
#' #' * latest_reply_created | ||
#' #' * latest_reply_member_name | ||
#' #' * resource | ||
#' #' | ||
#' #' @references | ||
#' #' \url{https://www.meetup.com/meetup_api/docs/:urlname/boards/} | ||
#' #'@examples | ||
#' #' \dontrun{ | ||
#' #' urlname <- "rladies-nashville" | ||
#' #' meetup_boards <- get_boards(urlname = urlname) | ||
#' #'} | ||
#' #' @export | ||
#' get_boards <- function(urlname, | ||
#' verbose = meetupr_verbose()) { | ||
#' api_path <- paste0(urlname, "/boards") | ||
#' res <- .fetch_results(api_path = api_path, verbose = verbose) | ||
#' tibble::tibble( | ||
#' id = purrr::map_int(res, "id"), | ||
#' name = purrr::map_chr(res, "name"), | ||
#' description = purrr::map_chr(res, "description"), | ||
#' created = .date_helper(purrr::map_dbl(res, "created")), | ||
#' updated = .date_helper(purrr::map_dbl(res, "updated")), | ||
#' post_count = purrr::map_int(res, "post_count", .default = NA), | ||
#' discussion_count = purrr::map_int(res, "discussion_count", .default = NA), | ||
#' latest_reply_created = .date_helper(purrr::map_dbl(res, c("latest_reply", "created"), .default = NA)), | ||
#' latest_reply_member_name = purrr::map_chr(res, c("latest_reply", "member", "name"), .default = NA), | ||
#' resource = res | ||
#' ) | ||
#' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,96 @@ | ||
#' #' Meetup pro functions | ||
#' #' | ||
#' #' The pro functions only work if the querying users | ||
#' #' had a meetup pro account. | ||
#' #' | ||
#' #' \describe{ | ||
#' #' \item{get_pro_groups}{Get the current meetup members from a pro meetup group} | ||
#' #' \item{get_pro_events}{Get pro group events for the enxt 30 days} | ||
#' #' } | ||
#' #' | ||
#' #' @template urlname | ||
#' #' @template verbose | ||
#' #' | ||
#' #' @references | ||
#' #' \url{https://www.meetup.com/meetup_api/docs/pro/:urlname/groups/} | ||
#' #' \url{https://www.meetup.com/meetup_api/docs/:urlname/events/#list} | ||
#' #' | ||
#' #' @examples | ||
#' #' \dontrun{ | ||
#' #' urlname <- "rladies" | ||
#' #' members <- get_pro_groups(urlname) | ||
#' #' | ||
#' #' past_events <- get_events(urlname = urlname, | ||
#' #' event_status = "past") | ||
#' #' upcoming_events <- get_events(urlname = urlname, | ||
#' #' event_status = "upcoming") | ||
#' #'} | ||
#' #' | ||
#' #' @return A tibble with meetup information | ||
#' Meetup pro functions | ||
#' | ||
#' The pro functions only work if the querying users | ||
#' had a meetup pro account. | ||
#' | ||
#' #' @rdname meetup_pro | ||
#' #' @export | ||
#' #' @importFrom purrr map_int map_chr map_dbl | ||
#' #' @importFrom tibble tibble | ||
#' get_pro_groups <- function( | ||
#' urlname, | ||
#' ..., | ||
#' extra_graphql = NULL, | ||
#' token = meetup_token() | ||
#' ) { | ||
#' ellipsis::check_dots_empty() | ||
#' @template urlname | ||
#' @param ... Should be empty. Used for parameter expansion | ||
#' @template extra_graphql | ||
#' @template token | ||
#' @param status Which status the events should have. | ||
#' | ||
#' dt <- gql_events( | ||
#' urlname = urlname, | ||
#' .extra_graphql = extra_graphql, | ||
#' .token = token | ||
#' ) | ||
#' @references | ||
#' \url{https://www.meetup.com/api/schema/#ProNetwork} | ||
#' | ||
#' tibble( | ||
#' group_sorter(res), | ||
#' created = .date_helper(map_dbl(res, "founded_date")), | ||
#' members = map_chr(res, "member_count"), | ||
#' upcoming_events = map_int(res, "upcoming_events"), | ||
#' past_events = map_int(res, "past_events"), | ||
#' res = res | ||
#' ) | ||
#' } | ||
#' | ||
#' | ||
#' #' @rdname meetup_pro | ||
#' #' @importFrom tibble tibble | ||
#' #' @export | ||
#' get_pro_events <- function(urlname, | ||
#' verbose = meetupr_verbose() | ||
#' ){ | ||
#' | ||
#' api_path <- sprintf("pro/%s/events", urlname) | ||
#' res <- .fetch_results(api_path = api_path, verbose = verbose) | ||
#' | ||
#' group <- lapply(res, function(x) x[["chapter"]]) | ||
#' group <- tibble(group_sorter(group), res = group) | ||
#' names(group) <- paste0("group_", names(group)) | ||
#' | ||
#' events <- lapply(res, function(x) x[[1]]) | ||
#' @examples | ||
#' \dontrun{ | ||
#' urlname <- "rladies" | ||
#' members <- get_pro_groups(urlname) | ||
#' | ||
#' tibble( | ||
#' event_sorter(events), | ||
#' group | ||
#' ) | ||
#' past_events <- get_pro_events(urlname = urlname, | ||
#' status = "PAST") | ||
#' upcoming_events <- get_pro_events(urlname = urlname, | ||
#' status = "UPCOMING") | ||
#' all_events <- get_pro_events(urlname = urlname) | ||
#' } | ||
#' @name meetup_pro | ||
#' @return A tibble with meetup pro information | ||
NULL | ||
|
||
#' Get pro groups information | ||
#' @export | ||
#' @describeIn meetup_pro retrieve groups in a pro network | ||
get_pro_groups <- function( | ||
urlname, | ||
..., | ||
extra_graphql = NULL, | ||
token = meetup_token() | ||
) { | ||
ellipsis::check_dots_empty() | ||
|
||
dt <- gql_get_pro_groups( | ||
urlname = urlname, | ||
.extra_graphql = extra_graphql, | ||
.token = token | ||
) | ||
dt <- rename(dt, | ||
created = foundedDate, | ||
members = memberships.count, | ||
join_mode = joinMode, | ||
category_id = category.id, | ||
category_name = category.name, | ||
country = country_name, | ||
past_events_count = pastEvents.count, | ||
upcoming_events_count = upcomingEvents.count, | ||
membership_status = membershipMetadata.status, | ||
is_private = isPrivate | ||
|
||
) | ||
|
||
dt$created <- anytime::anytime(dt$created) | ||
dt | ||
} | ||
|
||
#' Get pro events information | ||
#' @export | ||
#' @describeIn meetup_pro retrieve events from a pro network | ||
get_pro_events <- function( | ||
urlname, | ||
status = NULL, | ||
..., | ||
extra_graphql = NULL, | ||
token = meetup_token() | ||
) { | ||
ellipsis::check_dots_empty() | ||
|
||
dt <- gql_get_pro_events( | ||
urlname = urlname, | ||
status = status, | ||
.extra_graphql = extra_graphql, | ||
.token = token | ||
) | ||
if(nrow(dt) == 0) return(NULL) | ||
|
||
# replace dot with underscore | ||
names(dt) <- gsub("\\.", "_", names(dt)) | ||
|
||
dt <- rename(dt, | ||
link = eventUrl, | ||
event_type = eventType, | ||
venue_zip = venue_postalCode | ||
) | ||
dt$time <- anytime::anytime(dt$dateTime) | ||
|
||
remove(dt, | ||
dateTime) | ||
} |
Oops, something went wrong.