Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maciej 294 rename get functions #296

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: GitStats
Title: Get Statistics from Git Hosting Services
Version: 0.1.0.9004
Version: 0.1.0.9005
Authors@R: c(
person(given = "Maciej", family = "Banaś", email = "[email protected]", role = c("aut", "cre")),
person(given = "Kamil", family = "Koziej", email = "[email protected]", role = "aut"),
Expand Down
11 changes: 6 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
export("%>%")
export(create_gitstats)
export(get_commits)
export(get_orgs)
export(get_repos)
export(get_repos_contributors)
export(get_users)
export(plot_commits)
export(plot_repos)
export(pull_commits)
export(pull_repos)
export(pull_repos_contributors)
export(pull_users)
export(reset)
export(reset_language)
export(set_host)
export(set_params)
export(set_team_member)
export(setup)
export(show_commits)
export(show_orgs)
export(show_repos)
importFrom(R6,R6Class)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert_danger)
Expand Down
11 changes: 6 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
GitStats (development version)

GitStats 0.1.0.9004

- changed names of `get_*` to `pull_*` functions; `get_*` functions are now to retrieve already pulled data from GitStats object (I: #294),
- changed name of `setup` to `set_params` function (I: #294),
- set new name for `set_connection` function: `set_host` as it is more informative (and shorter) (I: #271),
- changed name of a function: `add_team_member` to `set_team_member` (I: #271),
- added setting tokens by default - if a user does have all the PATs set up in environment variables (as e.g. `GITHUB_PAT` or `GITLAB_PAT`), there is no need to pass them as an arugment to `set_connection` (I: #120 PR: #268),
- added `get_users()` function to pull information on users (I: #199 PR: #238),
- added `pull_users()` function to pull information on users (I: #199 PR: #238),
- added possibility of scanning whole internal git platforms if no `orgs` are passed (I: #258),
- added switching to REST engine in case GraphQL fails with 502 error (I: #225 PRs: #227 (for repos) #261 (for commits))
- added `show_orgs()` function to print all organizations (I: #283),
- added `get_orgs()` function to print all organizations (I: #283),
- added GraphQL engine for getting GitLab repos by organization (I: #218 PR: #233)
- removed `contributors` as basic stat when pulling `repos` by `org` and by `phrase` to improve speed of pulling repositories data. Added `get_repos_contributors()` user function and `add_contributors` parameter to `get_repos()` function to add conditionally information on contributors to repositories table (I: #235 PRs: #243 #264)
- removed `contributors` as basic stat when pulling `repos` by `org` and by `phrase` to improve speed of pulling repositories data. Added `pull_repos_contributors()` user function and `add_contributors` parameter to `pull_repos()` function to add conditionally information on contributors to repositories table (I: #235 PRs: #243 #264)
- added resetting all settings to default with `reset()` function (I: #270)
- added resetting language in your search preferences with `reset_language()` or setting `language` parameter to `All` in `setup()` function (I: #231 PR: #265)
- OOP optimization: moved method on adding issues do repository table via REST to privates (I: #235 PR: #243)
Expand Down
2 changes: 1 addition & 1 deletion R/EngineGraphQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EngineGraphQL <- R6::R6Class("EngineGraphQL",
#' @description Get information on users in the form of table
#' @param users A character vector of users
#' @return A table
get_users = function(users) {
pull_users = function(users) {
purrr::map(users, function(user) {
private$pull_user(username = user) %>%
private$prepare_user_table()
Expand Down
18 changes: 9 additions & 9 deletions R/EngineGraphQLGitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
},

#' @description Get all groups from GitLab.
get_orgs = function() {
pull_orgs = function() {
end_cursor <- NULL
has_next_page <- TRUE
full_orgs_list <- list()
Expand All @@ -45,14 +45,14 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return A table.
get_repos = function(org,
pull_repos = function(org,
settings) {
if (settings$search_param %in% c("org", "team")) {
if (settings$search_param == "org") {
if (!private$scan_all) {
cli::cli_alert_info("[GitHub][Engine:{cli::col_yellow('GraphQL')}][org:{org}] Pulling repositories...")
}
repos_table <- private$pull_repos(
repos_table <- private$pull_repos_from_org(
from = "org",
org = org
) %>%
Expand Down Expand Up @@ -83,7 +83,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return Nothing.
get_repos_supportive = function(org,
pull_repos_supportive = function(org,
settings) {
NULL
},
Expand All @@ -95,11 +95,11 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits = function(org,
pull_commits = function(org,
date_from,
date_until,
settings) {
repos_table <- self$get_repos(
repos_table <- self$pull_repos(
org = org,
settings = list(search_param = "org")
)
Expand Down Expand Up @@ -146,7 +146,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits_supportive = function(org,
pull_commits_supportive = function(org,
date_from,
date_until = Sys.date(),
settings) {
Expand All @@ -160,7 +160,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
# @param org An organization.
# @param user A user.
# @return A list of repositories from organization.
pull_repos = function(from,
pull_repos_from_org = function(from,
org = NULL,
user = NULL) {
full_repos_list <- list()
Expand Down Expand Up @@ -200,7 +200,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub",
for (member in team) {
for (login in member$logins) {
user_repos <-
private$pull_repos(
private$pull_repos_from_org(
from = "user",
user = login
)
Expand Down
16 changes: 8 additions & 8 deletions R/EngineGraphQLGitLab.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab",
},

#' @description Get all groups from GitLab.
get_orgs = function() {
pull_orgs = function() {
group_cursor <- ""
has_next_page <- TRUE
full_orgs_list <- list()
Expand All @@ -43,14 +43,14 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return A table.
get_repos = function(org,
pull_repos = function(org,
settings) {
org <- gsub("%2f", "/", org)
if (settings$search_param == "org") {
if (!private$scan_all) {
cli::cli_alert_info("[GitLab][Engine:{cli::col_yellow('GraphQL')}][org:{org}] Pulling repositories...")
}
repos_table <- private$pull_repos(
repos_table <- private$pull_repos_from_org(
from = "org",
org = org
) %>%
Expand All @@ -65,7 +65,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return Nothing.
get_repos_supportive = function(org,
pull_repos_supportive = function(org,
settings) {
NULL
},
Expand All @@ -79,7 +79,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits = function(org,
pull_commits = function(org,
date_from,
date_until = Sys.date(),
settings) {
Expand All @@ -94,9 +94,9 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab",
# @param org An organization.
# @param user A user.
# @return A list of repositories from organization.
pull_repos = function(from,
org = NULL,
users = NULL) {
pull_repos_from_org = function(from,
org = NULL,
users = NULL) {
full_repos_list <- list()
next_page <- TRUE
repo_cursor <- ""
Expand Down
22 changes: 11 additions & 11 deletions R/EngineRestGitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
#' @param org An organization
#' @param settings A list of `GitStats` settings.
#' @return Table of repositories.
get_repos = function(org,
pull_repos = function(org,
settings) {
if (settings$search_param == "phrase") {
if (!private$scan_all) {
Expand All @@ -21,7 +21,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
) %>%
private$tailor_repos_info() %>%
private$prepare_repos_table() %>%
private$get_repos_issues()
private$pull_repos_issues()
} else {
repos_table <- NULL
}
Expand All @@ -33,7 +33,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return A table of repositories.
get_repos_supportive = function(org,
pull_repos_supportive = function(org,
settings) {
repos_table <- NULL
if (settings$search_param %in% c("org")) {
Expand All @@ -45,7 +45,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
) %>%
private$tailor_repos_info() %>%
private$prepare_repos_table() %>%
private$get_repos_issues()
private$pull_repos_issues()
}
return(repos_table)
},
Expand All @@ -59,7 +59,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits = function(org,
pull_commits = function(org,
date_from,
date_until = Sys.date(),
settings) {
Expand All @@ -72,11 +72,11 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits_supportive = function(org,
pull_commits_supportive = function(org,
date_from,
date_until = Sys.date(),
settings) {
repos_table <- self$get_repos_supportive(
repos_table <- self$pull_repos_supportive(
org = org,
settings = list(search_param = "org")
)
Expand All @@ -102,15 +102,15 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
commits_table <- repos_list_with_commits %>%
private$tailor_commits_info(org = org) %>%
private$prepare_commits_table() %>%
private$get_commits_stats()
private$pull_commits_stats()

return(commits_table)
},

#' @description A method to add information on repository contributors.
#' @param repos_table A table of repositories.
#' @return A table of repositories with added information on contributors.
get_repos_contributors = function(repos_table) {
pull_repos_contributors = function(repos_table) {
if (nrow(repos_table) > 0) {
if (!private$scan_all) {
cli::cli_alert_info("[GitHub][Engine:{cli::col_green('REST')}] Pulling contributors...")
Expand Down Expand Up @@ -320,7 +320,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
# @description A method to add information on open and closed issues of a repository.
# @param repos_table A table of repositories.
# @return A table of repositories with added information on issues.
get_repos_issues = function(repos_table) {
pull_repos_issues = function(repos_table) {
if (nrow(repos_table) > 0) {
repos_iterator <- paste0(repos_table$organization, "/", repos_table$name)
issues <- purrr::map_dfr(repos_iterator, function(repo_path) {
Expand Down Expand Up @@ -474,7 +474,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub",
# @description A wrapper to pull stats for all commits.
# @param commits_table A table with commits.
# @return A data.frame
get_commits_stats = function(commits_table) {
pull_commits_stats = function(commits_table) {
cli::cli_alert_info("[GitHub][Engine:{cli::col_green('REST')}] Pulling commits stats...")
repo_fullnames <- paste0(commits_table$organization, "/", commits_table$repository)
commit_stats <- purrr::map2_dfr(commits_table$id, repo_fullnames,
Expand Down
20 changes: 10 additions & 10 deletions R/EngineRestGitLab.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
#' @param org A character, a group of projects.
#' @param settings A list of `GitStats` settings.
#' @return A table.
get_repos = function(org,
pull_repos = function(org,
settings) {
if (settings$search_param == "phrase") {
if (!private$scan_all) {
Expand All @@ -22,7 +22,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
) %>%
private$tailor_repos_info() %>%
private$prepare_repos_table() %>%
private$get_repos_issues()
private$pull_repos_issues()
} else if (settings$search_param == "team") {
if (!private$scan_all) {
cli::cli_alert_info("[GitLab][Engine:{cli::col_green('REST')}][org:{gsub('%2f', '/', org)}][team:{settings$team_name}] Pulling repositories...")
Expand All @@ -31,9 +31,9 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
repos_table <- private$pull_repos_from_org(org) %>%
private$tailor_repos_info() %>%
private$prepare_repos_table() %>%
private$get_repos_issues()
private$pull_repos_issues()
suppressMessages({
repos_table <- self$get_repos_contributors(
repos_table <- self$pull_repos_contributors(
repos_table = repos_table
) %>%
private$filter_repos_by_team(team = settings$team)
Expand All @@ -48,7 +48,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
#' @param org An organization.
#' @param settings A list of `GitStats` settings.
#' @return Nothing.
get_repos_supportive = function(org,
pull_repos_supportive = function(org,
settings) {
repos_table <- NULL
if (settings$search_param == "org") {
Expand All @@ -59,15 +59,15 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
repos_table <- private$pull_repos_from_org(org) %>%
private$tailor_repos_info() %>%
private$prepare_repos_table() %>%
private$get_repos_issues()
private$pull_repos_issues()
}
return(repos_table)
},

#' @description A method to add information on repository contributors.
#' @param repos_table A table of repositories.
#' @return A table of repositories with added information on contributors.
get_repos_contributors = function(repos_table) {
pull_repos_contributors = function(repos_table) {
if (nrow(repos_table) > 0) {
if (!private$scan_all) {
cli::cli_alert_info("[GitLab][Engine:{cli::col_green('REST')}] Pulling contributors...")
Expand Down Expand Up @@ -101,11 +101,11 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
#' @param date_until An end date to look commits for.
#' @param settings A list of `GitStats` settings.
#' @return A table of commits.
get_commits = function(org,
pull_commits = function(org,
date_from,
date_until = Sys.date(),
settings) {
repos_table <- self$get_repos_supportive(
repos_table <- self$pull_repos_supportive(
org = org,
settings = list(search_param = "org")
)
Expand Down Expand Up @@ -280,7 +280,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab",
# @description A method to add information on open and closed issues of a repository.
# @param repos_table A table of repositories.
# @return A table of repositories with added information on issues.
get_repos_issues = function(repos_table) {
pull_repos_issues = function(repos_table) {
if (nrow(repos_table) > 0) {
issues <- purrr::map(repos_table$id, function(repos_id) {
id <- gsub("gid://gitlab/Project/", "", repos_id)
Expand Down
Loading
Loading