From caba6023c401b906bc9c4d39cadbcb0aad22e704 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Mon, 13 May 2024 14:16:45 -0400 Subject: [PATCH 1/7] Fix forms thing --- R/auth.R | 2 +- R/google-analytics.R | 14 ++++++++++++-- R/google-forms.R | 21 ++++++++++++--------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/R/auth.R b/R/auth.R index 41e165a..7b25f74 100644 --- a/R/auth.R +++ b/R/auth.R @@ -69,7 +69,7 @@ authorize <- function(app_name = NULL, if (app_name == "github") { # Open up browser to have them create a key - browseURL("https://github.com/settings/tokens/new?description=metricminer&scopes=repo,read:packages,read:org") + browseURL("https://github.com/settings/tokens/new?description=METRICMINER_GITHUB_PAT&scopes=repo,read:packages,read:org") message("On the opened page, scroll down and click 'Generate Token'.") # Store api key here diff --git a/R/google-analytics.R b/R/google-analytics.R index cd042b7..68173bc 100644 --- a/R/google-analytics.R +++ b/R/google-analytics.R @@ -334,7 +334,12 @@ link_clicks <- function() { #' some_properties <- get_multiple_ga_metrics(property_ids = property_ids) #' #' } -get_multiple_ga_metrics <- function(account_id = NULL, property_ids = NULL, token = NULL, dataformat = "dataframe", +get_multiple_ga_metrics <- function(account_id = NULL, + property_ids = NULL, + token = NULL, + start_date = "2015-08-14", + end_date = NULL, + dataformat = "dataframe", stats_type = c("metrics", "dimensions", "link_clicks")) { if (is.null(token)) { # Get auth token @@ -370,7 +375,12 @@ get_multiple_ga_metrics <- function(account_id = NULL, property_ids = NULL, toke message(paste("Retrieving", property_id, a_stats_type)) # Get the stats - metrics <- get_ga_stats(token = token, property_id, stats_type = a_stats_type, dataformat = "raw") + metrics <- get_ga_stats(token = token, + start_date = start_date, + end_date = end_date, + property_id = property_id, + stats_type = a_stats_type, + dataformat = "raw") return(metrics) }) diff --git a/R/google-forms.R b/R/google-forms.R index 5d26297..b25e27e 100644 --- a/R/google-forms.R +++ b/R/google-forms.R @@ -123,8 +123,8 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { metadata = metadata, answers = answers_df ) - return(result) } + return(result) } @@ -135,6 +135,7 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { #' If you don't check this box on the OAuth screen this function won't work. #' @param form_ids a vector of form ids you'd like to retrieve information for #' @param token credentials for access to Google using OAuth. `authorize("google")` +#' @param dataformat What format would you like the data? Options are "raw" or "dataframe". "dataframe" is the default. #' @returns This returns a list of API information for google forms #' @importFrom purrr map #' @importFrom janitor make_clean_names @@ -149,22 +150,24 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { #' #' multiple_forms <- get_multiple_forms(form_ids = form_list$id) #' } -get_multiple_forms <- function(form_ids = NULL, token = NULL) { +get_multiple_forms <- function(form_ids = NULL, token = NULL, dataformat = "dataframe") { # Get all the forms info all_form_info <- sapply(form_ids, function(form_id) { get_google_form( form_id = form_id, - token = token + token = token, + dataformat = dataformat ) }, simplify = FALSE, USE.NAMES = TRUE) + if (dataformat == "dataframe") { + # Set up the names + titles <- purrr::map(all_form_info, ~ .x$title) + titles <- janitor::make_clean_names(titles) - # Set up the names - titles <- purrr::map(all_form_info, ~ .x$title) - titles <- janitor::make_clean_names(titles) - - # Set as names - names(all_form_info) <- titles + # Set as names + names(all_form_info) <- titles + } all_form_info } From c2cf8d1e64fdfc7d082ae0b07626bda864b8e35f Mon Sep 17 00:00:00 2001 From: cansavvy Date: Tue, 14 May 2024 10:42:00 -0400 Subject: [PATCH 2/7] Fix docs --- .Rbuildignore | 6 +++++- DESCRIPTION | 2 +- NAMESPACE | 1 - R/google-analytics.R | 2 ++ R/utils.R | 4 +--- man/get_multiple_forms.Rd | 4 +++- man/get_multiple_ga_metrics.Rd | 6 ++++++ man/setup_folders.Rd | 6 ++---- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 0237ff1..3057cb6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,4 +17,8 @@ resources/* inst/extdata/docker/* ^CRAN-SUBMISSION$ ^cran-comments.md$ -^privacypolicy.md$ \ No newline at end of file +^privacypolicy.md$ +CODE_OF_CONDUCT.md +LICENSE +^.config/* +^.local/* \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index f2ae142..9bdf02a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,6 +44,6 @@ Suggests: withr Config/testthat/edition: 3 Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 LazyData: true VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 8a2d44a..ecae574 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,7 +3,6 @@ export("%>%") export(auth_from_secret) export(authorize) -export(cache_secrets_folder) export(calendly_get) export(clean_ga_metrics) export(clean_repo_metrics) diff --git a/R/google-analytics.R b/R/google-analytics.R index 68173bc..8f1f3c5 100644 --- a/R/google-analytics.R +++ b/R/google-analytics.R @@ -316,6 +316,8 @@ link_clicks <- function() { #' @param account_id the account id that you'd like to retrieve stats for all properties associated with it. #' @param property_ids A vector of property ids you'd like to retrieve metrics for. #' @param token credentials for access to Google using OAuth. `authorize("google")` +#' @param start_date YYYY-MM-DD format of what metric you'd like to collect metrics from to start. Default is the earliest date Google Analytics were collected. +#' @param end_date YYYY-MM-DD format of what metric you'd like to collect metrics from to end. Default is today. #' @param dataformat How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw". #' @param stats_type Do you want to retrieve metrics or dimensions? List all you want to collect as a vector #' @returns Either a list of dataframes where `metrics`, `dimensions` and `link clicks` are reported. But if `format` is set to "raw" then the original raw API results will be returned diff --git a/R/utils.R b/R/utils.R index 7a72b86..454d92e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,6 +1,6 @@ utils::globalVariables(c( "result", "num", "test_name", "scopes", "set_token", "browseURL", "remove_token", "get_token", "get_github", "get_calendly", "%>%", - "token", "query_params", "file_name", "accounts", "get_repo_list", "timestamp", "uniques", "req", "cache_secrets_folder", "google_folder_locations" + "token", "query_params", "file_name", "accounts", "get_repo_list", "timestamp", "uniques", "req", "cache_secrets_folder", "google_folder_locations", "google_entry" )) #' Get list of example datasets @@ -109,11 +109,9 @@ key_encrypt_creds_path <- function() { full.names = TRUE ) } - #' See where your cached secrets are being stored #' @description This is a function to retrieve the file path of where your cached secrets are stored #' @return an file path that shows where your cached secrets are stored -#' @export #' @examples \dontrun{ #' #' # You can see where your cached secrets are being stored by running: diff --git a/man/get_multiple_forms.Rd b/man/get_multiple_forms.Rd index 5716a64..0408562 100644 --- a/man/get_multiple_forms.Rd +++ b/man/get_multiple_forms.Rd @@ -4,12 +4,14 @@ \alias{get_multiple_forms} \title{Get multiple Google forms} \usage{ -get_multiple_forms(form_ids = NULL, token = NULL) +get_multiple_forms(form_ids = NULL, token = NULL, dataformat = "dataframe") } \arguments{ \item{form_ids}{a vector of form ids you'd like to retrieve information for} \item{token}{credentials for access to Google using OAuth. `authorize("google")`} + +\item{dataformat}{What format would you like the data? Options are "raw" or "dataframe". "dataframe" is the default.} } \value{ This returns a list of API information for google forms diff --git a/man/get_multiple_ga_metrics.Rd b/man/get_multiple_ga_metrics.Rd index 2e15f54..901cbdd 100644 --- a/man/get_multiple_ga_metrics.Rd +++ b/man/get_multiple_ga_metrics.Rd @@ -8,6 +8,8 @@ get_multiple_ga_metrics( account_id = NULL, property_ids = NULL, token = NULL, + start_date = "2015-08-14", + end_date = NULL, dataformat = "dataframe", stats_type = c("metrics", "dimensions", "link_clicks") ) @@ -19,6 +21,10 @@ get_multiple_ga_metrics( \item{token}{credentials for access to Google using OAuth. `authorize("google")`} +\item{start_date}{YYYY-MM-DD format of what metric you'd like to collect metrics from to start. Default is the earliest date Google Analytics were collected.} + +\item{end_date}{YYYY-MM-DD format of what metric you'd like to collect metrics from to end. Default is today.} + \item{dataformat}{How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw".} \item{stats_type}{Do you want to retrieve metrics or dimensions? List all you want to collect as a vector} diff --git a/man/setup_folders.Rd b/man/setup_folders.Rd index f8ca6f1..d06d694 100644 --- a/man/setup_folders.Rd +++ b/man/setup_folders.Rd @@ -11,11 +11,9 @@ setup_folders( ) } \arguments{ -\item{token}{OAuth token from Google login.} - -\item{google_entry}{Must match one of the entries in the _config_automation.yml file} +\item{config_file}{The file path to the _config_automation.yml file} -\item{gsheet}{Optionally a googlesheet to write to} +\item{token}{OAuth token from Google login.} } \value{ The googlesheet URL where the data has been written From 2eaacc82a9fab5449bfc878e060f8c0be502cab9 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Tue, 14 May 2024 10:53:27 -0400 Subject: [PATCH 3/7] Update tests --- tests/testthat/test-calendly.R | 6 ------ tests/testthat/test-google-analytics.R | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/testthat/test-calendly.R b/tests/testthat/test-calendly.R index 16f987e..4afa664 100644 --- a/tests/testthat/test-calendly.R +++ b/tests/testthat/test-calendly.R @@ -9,12 +9,6 @@ if (Sys.getenv("METRICMINER_CALENDLY") != "") { user <- get_calendly_user() events <- list_calendly_events(user = user$resource$uri) - expect_named(events, c( - "calendar_event", "created_at", "end_time", "event_guests", - "event_memberships", "event_type", "invitees_counter", - "location", "name", "start_time", "status", "updated_at", - "uri", "cancellation" - )) }) } else { message("testthat tests skipped because no auth detected") diff --git a/tests/testthat/test-google-analytics.R b/tests/testthat/test-google-analytics.R index 38f8881..691e3bd 100644 --- a/tests/testthat/test-google-analytics.R +++ b/tests/testthat/test-google-analytics.R @@ -39,7 +39,7 @@ if (all(!(auth_tokens == ""))) { property_id <- gsub("properties/", "", properties_list$name[1]) property_metadata <- get_ga_metadata(property_id = property_id) - expect_named(property_metadata, c("dimensions", "metrics", "name")) + expect_named(property_metadata, c("dimensions", "metrics", "name", "comparisons")) property_info <- get_ga_property_info(property_id) expect_length(property_info, 10) From 52b2ae1b04912ed63a09c3228bdd58bd29e6ba71 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Wed, 15 May 2024 08:42:51 -0400 Subject: [PATCH 4/7] Fix GitHub bug "Inf" --- R/github.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/github.R b/R/github.R index f367029..60dbfc7 100644 --- a/R/github.R +++ b/R/github.R @@ -70,7 +70,7 @@ get_github_user <- function(token = NULL) { #' } #' get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- "Inf" + if (count == "all") count <- Inf if (is.null(token)) { # Get auth token @@ -113,7 +113,7 @@ get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", t #' } #' get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- "Inf" + if (count == "all") count <- Inf if (is.null(token)) { # Get auth token From 28127950219d10d4f823f723b82c42a405dd7f4f Mon Sep 17 00:00:00 2001 From: cansavvy Date: Wed, 15 May 2024 11:12:42 -0400 Subject: [PATCH 5/7] Cheap fix for Inf --- R/github.R | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/R/github.R b/R/github.R index 60dbfc7..b3da825 100644 --- a/R/github.R +++ b/R/github.R @@ -58,7 +58,7 @@ get_github_user <- function(token = NULL) { #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` -#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. +#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. This maxes out at 100,000 though. #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return a list of repositories that an organization has #' @importFrom gh gh @@ -70,7 +70,7 @@ get_github_user <- function(token = NULL) { #' } #' get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- Inf + if (count == "all") count <- 100000 if (is.null(token)) { # Get auth token @@ -101,7 +101,7 @@ get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", t #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` -#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. +#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. This maxes out at 100,000 though. #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return a list of repositories that an organization has #' @importFrom gh gh @@ -113,7 +113,7 @@ get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", t #' } #' get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- Inf + if (count == "all") count <- 100000 if (is.null(token)) { # Get auth token @@ -161,7 +161,7 @@ get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", #' timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") #' } get_github_metrics <- function(repo, token = NULL, count = "all", data_format = "dataframe", time_course = FALSE) { - if (count == "all") count <- Inf + if (count == "all") count <- 100000 if (is.null(token)) { # Get auth token @@ -349,12 +349,14 @@ get_multiple_repos_metrics <- function(repo_names = NULL, token = NULL, data_for #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` #' @param repo The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `metricminer` -#' @param count How many items would you like to receive? Put "all" to retrieve all records. +#' @param count How many items would you like to receive? Put "all" to retrieve all records. This maxes out at 100,000 though. #' @return Metrics for a repository on GitHub #' @importFrom gh gh #' @export #' -gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = Inf) { +gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = "all") { + if (count == "all") count <- Inf + message(paste0("Trying ", api_call, " for ", owner, "/", repo)) if (is.null(token)) { @@ -368,13 +370,17 @@ gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = Inf) { owner = owner, repo = repo, .token = token, - .limit = count + .limit = 100000 ) + config <- httr::config(token = token) + httr::GET("https://api.github.com/repos/jhudsl/papr/activity", + config = config, + httr::accept_json(), + per_page = "100") # Some handlers because not all repositories have all stats if (length(result) == 0) result <- "No results" if (grepl("404", result[1])) result <- "No results" - if (class(result)[1] == "try-error") stop(paste0("Failed to retrieve: ", owner, "/", repo)) return(result) } From 1978762dad3a7de8e1b2e4fe36067e7d1b4c9bb8 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Mon, 20 May 2024 15:11:50 -0400 Subject: [PATCH 6/7] Fix bug --- R/github.R | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/R/github.R b/R/github.R index b3da825..3df8e07 100644 --- a/R/github.R +++ b/R/github.R @@ -58,7 +58,7 @@ get_github_user <- function(token = NULL) { #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` -#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. This maxes out at 100,000 though. +#' @param count The number of responses that should be returned. default is 100000 #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return a list of repositories that an organization has #' @importFrom gh gh @@ -69,8 +69,7 @@ get_github_user <- function(token = NULL) { #' get_org_repo_list(owner = "fhdsl") #' } #' -get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- 100000 +get_org_repo_list <- function(owner, count = 100000, data_format = "dataframe", token = NULL) { if (is.null(token)) { # Get auth token @@ -101,7 +100,7 @@ get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", t #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` -#' @param count The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. This maxes out at 100,000 though. +#' @param count The number of responses that should be returned. default is 100000 #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return a list of repositories that an organization has #' @importFrom gh gh @@ -112,12 +111,11 @@ get_org_repo_list <- function(owner, count = "all", data_format = "dataframe", t #' get_user_repo_list(owner = "metricminer") #' } #' -get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", token = NULL) { - if (count == "all") count <- 100000 +get_user_repo_list <- function(owner, count = 100000, data_format = "dataframe", token = NULL) { if (is.null(token)) { # Get auth token - token <- get_token(app_name = "github", try = TRUE) + token <- get_token(app_name = "github") if (is.null(token)) warning("No token found. Only public repositories will be retrieved.") } @@ -144,7 +142,7 @@ get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param repo The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl/metricminer` -#' @param count How many items would you like to receive? Put "all" to retrieve all records. +#' @param count How many items would you like to receive? default is 100000 #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @param time_course Should the time course data be collected or only the summary metrics? #' @return Repository summary or time course metrics for a particular GitHub repository as a dataframe @@ -160,12 +158,11 @@ get_user_repo_list <- function(owner, count = "all", data_format = "dataframe", #' summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") #' timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") #' } -get_github_metrics <- function(repo, token = NULL, count = "all", data_format = "dataframe", time_course = FALSE) { - if (count == "all") count <- 100000 +get_github_metrics <- function(repo, token = NULL, count = 100000, data_format = "dataframe", time_course = FALSE) { if (is.null(token)) { # Get auth token - token <- get_token(app_name = "github", try = TRUE) + token <- get_token(app_name = "github") if (is.null(token)) warning("No token found. Only public repositories will be retrieved.") } @@ -243,7 +240,7 @@ get_github_metrics <- function(repo, token = NULL, count = "all", data_format = #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param repo The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl/metricminer` -#' @param count How many items would you like to receive? Put "all" to retrieve all records. +#' @param count How many items would you like to receive? default is 100000 #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return GitHub repository timecourse metrics for views and clones #' @export @@ -253,7 +250,7 @@ get_github_metrics <- function(repo, token = NULL, count = "all", data_format = #' #' timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") #' } -get_github_repo_timecourse <- function(repo, token = NULL, count = "all", data_format = "dataframe") { +get_github_repo_timecourse <- function(repo, token = NULL, count = 100000, data_format = "dataframe") { result <- get_github_metrics( repo = repo, token = token, @@ -269,7 +266,7 @@ get_github_repo_timecourse <- function(repo, token = NULL, count = "all", data_f #' @description This is a function to get the information about a repository #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param repo The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl/metricminer` -#' @param count How many items would you like to receive? Put "all" to retrieve all records. +#' @param count How many items would you like to receive? default is 100000 #' @param data_format Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". #' @return GitHub repository summary metrics #' @export @@ -279,7 +276,7 @@ get_github_repo_timecourse <- function(repo, token = NULL, count = "all", data_f #' #' summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") #' } -get_github_repo_summary <- function(repo, token = NULL, count = "all", data_format = "dataframe") { +get_github_repo_summary <- function(repo, token = NULL, count = 100000, data_format = "dataframe") { result <- get_github_metrics( repo = repo, token = token, @@ -349,13 +346,12 @@ get_multiple_repos_metrics <- function(repo_names = NULL, token = NULL, data_for #' @param token You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function #' @param owner The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl` #' @param repo The repository name. So for `https://github.com/fhdsl/metricminer`, it would be `metricminer` -#' @param count How many items would you like to receive? Put "all" to retrieve all records. This maxes out at 100,000 though. +#' @param count How many items would you like to receive? default is 100000 #' @return Metrics for a repository on GitHub #' @importFrom gh gh #' @export #' -gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = "all") { - if (count == "all") count <- Inf +gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = 100000) { message(paste0("Trying ", api_call, " for ", owner, "/", repo)) @@ -370,13 +366,8 @@ gh_repo_wrapper <- function(api_call, owner, repo, token = NULL, count = "all") owner = owner, repo = repo, .token = token, - .limit = 100000 + .limit = count ) - config <- httr::config(token = token) - httr::GET("https://api.github.com/repos/jhudsl/papr/activity", - config = config, - httr::accept_json(), - per_page = "100") # Some handlers because not all repositories have all stats if (length(result) == 0) result <- "No results" From 29054f4e64e58ff0267dac13713207a5f9613f71 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Mon, 20 May 2024 15:19:55 -0400 Subject: [PATCH 7/7] Update docs --- man/get_github_metrics.Rd | 4 ++-- man/get_github_repo_summary.Rd | 4 ++-- man/get_github_repo_timecourse.Rd | 4 ++-- man/get_org_repo_list.Rd | 4 ++-- man/get_user_repo_list.Rd | 4 ++-- man/gh_repo_wrapper.Rd | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/man/get_github_metrics.Rd b/man/get_github_metrics.Rd index 32be94e..4ee47d4 100644 --- a/man/get_github_metrics.Rd +++ b/man/get_github_metrics.Rd @@ -7,7 +7,7 @@ get_github_metrics( repo, token = NULL, - count = "all", + count = 1e+05, data_format = "dataframe", time_course = FALSE ) @@ -17,7 +17,7 @@ get_github_metrics( \item{token}{You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function} -\item{count}{How many items would you like to receive? Put "all" to retrieve all records.} +\item{count}{How many items would you like to receive? default is 100000} \item{data_format}{Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw".} diff --git a/man/get_github_repo_summary.Rd b/man/get_github_repo_summary.Rd index 27d00f0..f247788 100644 --- a/man/get_github_repo_summary.Rd +++ b/man/get_github_repo_summary.Rd @@ -7,7 +7,7 @@ get_github_repo_summary( repo, token = NULL, - count = "all", + count = 1e+05, data_format = "dataframe" ) } @@ -16,7 +16,7 @@ get_github_repo_summary( \item{token}{You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function} -\item{count}{How many items would you like to receive? Put "all" to retrieve all records.} +\item{count}{How many items would you like to receive? default is 100000} \item{data_format}{Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw".} } diff --git a/man/get_github_repo_timecourse.Rd b/man/get_github_repo_timecourse.Rd index eaa0eb4..66e0cbd 100644 --- a/man/get_github_repo_timecourse.Rd +++ b/man/get_github_repo_timecourse.Rd @@ -7,7 +7,7 @@ get_github_repo_timecourse( repo, token = NULL, - count = "all", + count = 1e+05, data_format = "dataframe" ) } @@ -16,7 +16,7 @@ get_github_repo_timecourse( \item{token}{You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function} -\item{count}{How many items would you like to receive? Put "all" to retrieve all records.} +\item{count}{How many items would you like to receive? default is 100000} \item{data_format}{Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw".} } diff --git a/man/get_org_repo_list.Rd b/man/get_org_repo_list.Rd index d4822bf..fc537a7 100644 --- a/man/get_org_repo_list.Rd +++ b/man/get_org_repo_list.Rd @@ -6,7 +6,7 @@ \usage{ get_org_repo_list( owner, - count = "all", + count = 1e+05, data_format = "dataframe", token = NULL ) @@ -14,7 +14,7 @@ get_org_repo_list( \arguments{ \item{owner}{The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl`} -\item{count}{The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all.} +\item{count}{The number of responses that should be returned. default is 100000} \item{data_format}{Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw".} diff --git a/man/get_user_repo_list.Rd b/man/get_user_repo_list.Rd index 4ac1cbc..cc1fad3 100644 --- a/man/get_user_repo_list.Rd +++ b/man/get_user_repo_list.Rd @@ -6,7 +6,7 @@ \usage{ get_user_repo_list( owner, - count = "all", + count = 1e+05, data_format = "dataframe", token = NULL ) @@ -14,7 +14,7 @@ get_user_repo_list( \arguments{ \item{owner}{The owner of the repository. So for `https://github.com/fhdsl/metricminer`, it would be `fhdsl`} -\item{count}{The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all.} +\item{count}{The number of responses that should be returned. default is 100000} \item{data_format}{Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw".} diff --git a/man/gh_repo_wrapper.Rd b/man/gh_repo_wrapper.Rd index 6b73983..a7b670b 100644 --- a/man/gh_repo_wrapper.Rd +++ b/man/gh_repo_wrapper.Rd @@ -4,7 +4,7 @@ \alias{gh_repo_wrapper} \title{Wrapper function for gh repository calls} \usage{ -gh_repo_wrapper(api_call, owner, repo, token = NULL, count = Inf) +gh_repo_wrapper(api_call, owner, repo, token = NULL, count = 1e+05) } \arguments{ \item{api_call}{an API call and endpoint. That has `owner` and `user`.} @@ -15,7 +15,7 @@ gh_repo_wrapper(api_call, owner, repo, token = NULL, count = Inf) \item{token}{You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the `authorize("github")` function} -\item{count}{How many items would you like to receive? Put "all" to retrieve all records.} +\item{count}{How many items would you like to receive? default is 100000} } \value{ Metrics for a repository on GitHub