Skip to content

Commit

Permalink
Merge pull request #385 from r-world-devs/333-high-level-function-for…
Browse files Browse the repository at this point in the history
…-searching-code-blobs

Major changes for pulling by code, deprecations of team and language filtering.
  • Loading branch information
maciekbanas authored Apr 10, 2024
2 parents 15aeaca + 301844b commit e23e5a0
Show file tree
Hide file tree
Showing 47 changed files with 490 additions and 1,656 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.Rhistory
.RData
.Ruserdata
example_workflow_Roche.R
example_branch.R
devel
inst/doc
docs/
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 GitHub and GitLab
Version: 1.1.0.9005
Version: 1.1.0.9006
Authors@R: c(
person(given = "Maciej", family = "Banas", email = "[email protected]", role = c("aut", "cre")),
person(given = "Kamil", family = "Koziej", email = "[email protected]", role = "aut"),
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ export(get_release_logs)
export(get_repos)
export(get_users)
export(reset)
export(reset_language)
export(set_github_host)
export(set_gitlab_host)
export(set_params)
export(set_team_member)
export(show_data)
export(show_orgs)
export(verbose_off)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
- In `get_commits()` old parameters (`date_from` and `date_until`) were replaced with new, more concise (`since` and `until`).
- A new parameter (`verbose`) in settings has been introduced for limiting messages to user when pulling data - you can turn it on/off with `verbose_on()`/`verbose_off()` functions.

## Searching for code blobs in repositories:

- There is no longer `phrase` parameter to set in `set_params()`. If you choose to pull repositories by `code` (previously `phrase`), you then have to specify the `code` parameter directly in `get_repos()`. This seems to be more intuitive than setting whole GitStats for one `code` to search, especially when user wants to look for more than one code blob. ([#333](https://github.com/r-world-devs/GitStats/issues/333))

## Deprecate:

- Pulling by `team` and filtering by `language` is no longer supported - these features where quite heavy for the package performance and did not bring much added value. If user needs, he can always filter the output (formatted responses pulled from API) by contributors or language. ([#384](https://github.com/r-world-devs/GitStats/issues/384))

## New features:

- Added `get_release_logs()` ([#356](https://github.com/r-world-devs/GitStats/issues/356)).
Expand Down
60 changes: 40 additions & 20 deletions R/EngineGraphQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,21 @@ EngineGraphQL <- R6::R6Class("EngineGraphQL",
if (!private$scan_all && settings$verbose) {
cli::cli_alert_info("[Engine:{cli::col_yellow('GraphQL')}][org:{org}] Pulling releases...")
}
if (is.null(repos)) {
if (is.null(storage$repositories)) {
repos_table <- self$pull_repos(
org = org,
settings = settings
)
} else {
repos_table <- storage$repositories %>%
dplyr::filter(
organization == org
)
}
repos_names <- repos_table$repo_name
repos_names <- private$set_repositories(
repos = repos,
org = org,
settings = settings,
storage = storage
)
if (length(repos_names) > 0) {
releases_table <- private$pull_releases_from_org(
repos_names = repos_names,
org = org
) %>%
private$prepare_releases_table(org, date_from, date_until)
} else {
repos_names <- repos
releases_table <- NULL
}
releases_table <- private$pull_releases_from_org(
repos_names = repos_names,
org = org
) %>%
private$prepare_releases_table(org, date_from, date_until)

return(releases_table)
}

Expand Down Expand Up @@ -145,6 +138,33 @@ EngineGraphQL <- R6::R6Class("EngineGraphQL",
)
)
return(response)
},

# Set repositories for pulling commits or release logs
set_repositories = function(repos, org, settings, storage) {
if (is.null(repos)) {
if (is.null(storage$repositories)) {
repos_table <- self$pull_repos(
org = org,
settings = settings
)
} else {
if (settings$verbose) {
cli::cli_alert_warning(
cli::col_yellow("Using repositories stored in `GitStats` object.")
)
}
repos_table <- storage$repositories %>%
dplyr::filter(
organization == org
)
}
repos_names <- repos_table$repo_name
}
if (!is.null(repos)) {
repos_names <- repos
}
return(repos_names)
}
)
)
Loading

0 comments on commit e23e5a0

Please sign in to comment.