Skip to content

Commit

Permalink
Merge pull request #56 from ropensci-review-tools/repo-user-data
Browse files Browse the repository at this point in the history
rename main fns: repometrics_data_pkg/user
  • Loading branch information
mpadge authored Dec 10, 2024
2 parents 5380fbc + 6ec5f22 commit c3455d7
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 99 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: repometrics
Title: Metrics for Your Code Repository
Version: 0.1.3.003
Version: 0.1.3.006
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

export(repo_pkgstats_history)
export(repometrics_dashboard)
export(repometrics_data)
export(rm_data_repo)
export(rm_data_user)
export(repometrics_data_pkg)
export(repometrics_data_user)
importFrom(memoise,memoise)
7 changes: 5 additions & 2 deletions R/data-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ rm_data_libyears <- function (path) {
deps <- deps [which (!is.na (deps$published)), ]

rel <- rm_data_releases_from_gh_api (path, latest_only = TRUE)
rel_date <- as.Date (strftime (rel$published_at, format = "%Y-%m-%d"))
dt <- NA_real_
if (nrow (rel) > 0L) {
rel_date <- as.Date (strftime (rel$published_at, format = "%Y-%m-%d"))
dt <- difftime (deps$published, rel_date, units = "days")

dt <- difftime (deps$published, rel_date, units = "days")
}
deps$libyears <- as.numeric (dt) / 365.25 # In years

return (deps)
Expand Down
35 changes: 31 additions & 4 deletions R/data-repo.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
#' Collate 'repometrics' data for a local R package
#'
#' @inheritParams repo_pkgstats_history
#' @return A list with two main items:
#' \enumerate{
#' \item "pkgstats" Containing summary data from apply `pkgstats` routines
#' across the git history of the repository.
#' \item "cm" Containing data used to derive "CHAOSS metrics", primarily from
#' GitHub data.
#' }
#'
#' @export
repometrics_data_pkg <- function (path, step_days = 1L, num_cores = -1L) {

cli::cli_alert_info ("Extracting package statistics ...")
pkgstats <- repo_pkgstats_history (
path,
step_days = step_days,
num_cores = num_cores
)
cli::cli_alert_success ("Done!")

cli::cli_alert_info ("Extracting GitHub data ...")
rm <- rm_data_repo (path)
rm$contributors <- get_all_contribs (rm$contribs_from_log, rm$contribs_from_gh_api)
cli::cli_alert_success ("Done!")

list (pkgstats = pkgstats, rm = rm)
}

#' Calculate all repository data used in CHAOSS metrics
#' \url{https://chaoss.community/kb-metrics-and-metrics-models/}.
#'
Expand All @@ -23,7 +53,7 @@
#' \item `repo_from_gh_api` A `data.frame` of a single line, with several key
#' attributes of the repository on GitHub.
#' }
#' @export
#' @noRd
rm_data_repo <- function (path) {

checkmate::assert_directory_exists (path)
Expand Down Expand Up @@ -51,9 +81,6 @@ get_rm_data_fns <- function () {
data_fns <- data_fns [which (!grepl ("\\_internal$", data_fns))]
data_fns <- data_fns [which (!data_fns == "rm_data_repo")]

index <- grep ("user", data_fns)
data_fns <- data_fns [-index]

return (data_fns)
}

Expand Down
8 changes: 4 additions & 4 deletions R/data-user.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#' \item `issues` with information on all issues opened by user
#' }
#' @export
rm_data_user <- function (login,
ended_at = Sys.time (),
nyears = 1,
n_per_page = 100) {
repometrics_data_user <- function (login,
ended_at = Sys.time (),
nyears = 1,
n_per_page = 100) {

checkmate::assert_character (login, len = 1L)

Expand Down
6 changes: 3 additions & 3 deletions R/quarto-dashboard.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Start quarto dashboard with results of main \link{repometrics_data}
#' Start quarto dashboard with results of main \link{repometrics_data_pkg}
#' function.
#'
#' @param data Results of main \link{repometrics_data} function applied
#' to one package.
#' @param data Results of main \link{repometrics_data_pkg} function applied to
#' one package.
#' @param action One of "preview", to start and open a live preview of the
#' dashboard website, or "render" to render a static version without previewing
#' or opening.
Expand Down
29 changes: 0 additions & 29 deletions R/repometrics-data.R

This file was deleted.

2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.3.003",
"version": "0.1.3.006",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
8 changes: 4 additions & 4 deletions man/repometrics_dashboard.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/repometrics_data.Rd → man/repometrics_data_pkg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions man/rm_data_user.Rd → man/repometrics_data_user.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 0 additions & 39 deletions man/rm_data_repo.Rd

This file was deleted.

4 changes: 2 additions & 2 deletions tests/testthat/test-rm-data-gh-user.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ test_that ("rm user data internal structures", {
expect_named (dat$issue_cmts, nms)
})

test_that ("rm_data_user fn", {
test_that ("repometrics_data_user fn", {

Sys.setenv ("REPOMETRICS_TESTS" = "true")
dat_mocked <- mock_rm_data (repo = FALSE)

login <- "mpadge"
ended_at <- as.POSIXct ("2024-01-01T00:00:00")

dat <- rm_data_user (
dat <- repometrics_data_user (
login = login,
n_per_page = 1,
ended_at = ended_at,
Expand Down

0 comments on commit c3455d7

Please sign in to comment.