Skip to content

Commit

Permalink
Merge pull request #54 from ropensci-review-tools/user
Browse files Browse the repository at this point in the history
user data
  • Loading branch information
mpadge authored Dec 10, 2024
2 parents b3a70d8 + 159b4bf commit cc6a3ef
Show file tree
Hide file tree
Showing 47 changed files with 1,539 additions and 196 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.2.042
Version: 0.1.2.059
Authors@R:
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(cm_data)
export(repo_pkgstats_history)
export(repometrics_dashboard)
export(repometrics_data)
export(rm_data_repo)
export(rm_data_user)
importFrom(memoise,memoise)
2 changes: 1 addition & 1 deletion R/cm-metric-has-ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repo_has_ci_files <- function (path) {

has_gh_ci_tests <- function (path) {

ci_data <- cm_data_repo_from_gh_api (path)
ci_data <- rm_data_repo_from_gh_api (path)
h <- gert::git_log (repo = path, max = 1e6)
any (ci_data$sha %in% h$commit)
}
Expand Down
2 changes: 1 addition & 1 deletion R/cm-metric-issues-to-prs.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cm_metric_issues_to_prs <- function (path, end_date = Sys.Date ()) {

get_issues_in_period <- function (path, end_date = Sys.Date (), closed_only = FALSE) {

issues <- cm_data_issues_from_gh_api (path)
issues <- rm_data_issues_from_gh_api (path)
closed_dates <- as.Date (issues$closed_at)
start_date <- end_date - get_repometrics_period ()

Expand Down
2 changes: 1 addition & 1 deletion R/cm-metric-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cm_metric_label_inclusivity <- function (path, end_date = Sys.Date ()) {
# suppress no visible binding notes:
created_at <- NULL

issues_data <- cm_data_issues_from_gh_api (path)
issues_data <- rm_data_issues_from_gh_api (path)
issues_data$created_at <- as.Date (issues_data$created_at)

issues_data <- dplyr::filter (issues_data, created_at <= end_date)
Expand Down
2 changes: 1 addition & 1 deletion R/cm-metric-libyears.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @noRd
cm_metric_libyears <- function (path) {

deps <- cm_data_libyears (path)
deps <- rm_data_libyears (path)

c (mean = mean (deps$libyears), median = stats::median (deps$libyears))
}
2 changes: 1 addition & 1 deletion R/cm-metric-num-forks.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cm_metric_num_forks <- function (path, end_date = Sys.Date ()) {

forks <- cm_data_repo_forks (path)
forks <- rm_data_repo_forks (path)

start_date <- end_date - get_repometrics_period ()
index <- which (forks$created >= start_date & forks$created <= end_date)
Expand Down
8 changes: 4 additions & 4 deletions R/cm-metric-popularity.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ cm_metric_popularity <- function (path, end_date = Sys.Date ()) {
# suppress no visible binding notes:
timestamp <- aut_email <- aut_name <- created <- starred_at <- NULL

revdeps <- cm_data_dependencies_downstream (path)
revdeps <- rm_data_dependencies_downstream (path)

forks <- cm_data_repo_forks (path) |>
forks <- rm_data_repo_forks (path) |>
dplyr::filter (created <= end_date)

stars <- cm_data_repo_stargazers (path) |>
stars <- rm_data_repo_stargazers (path) |>
dplyr::filter (starred_at <= end_date)

log <- cm_data_gitlog (path) |>
log <- rm_data_gitlog (path) |>
dplyr::mutate (timestamp = as.Date (timestamp)) |>
dplyr::filter (timestamp <= end_date)
log_ctbs <- unique (log [, c ("aut_name", "aut_email")]) |>
Expand Down
2 changes: 1 addition & 1 deletion R/cm-metric-release-freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cm_metric_release_freq <- function (path, end_date = Sys.Date ()) {

start_date <- end_date - get_repometrics_period ()

releases <- cm_data_releases_from_gh_api (path) |>
releases <- rm_data_releases_from_gh_api (path) |>
dplyr::mutate (published_at = as.Date (published_at)) |>
dplyr::filter (published_at <= end_date)

Expand Down
2 changes: 1 addition & 1 deletion R/cm-metrics-change-req.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cm_metric_change_req <- function (path, end_date = Sys.Date ()) {

get_prs_in_period <- function (path, end_date = Sys.Date ()) {

prs <- cm_data_prs_from_gh_api (path)
prs <- rm_data_prs_from_gh_api (path)
prs <- prs [which (prs$merged), ]
closed_dates <- as.Date (prs$closed_at)
start_date <- end_date - get_repometrics_period ()
Expand Down
10 changes: 5 additions & 5 deletions R/cm-metrics-issue-response.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cm_metric_issue_response_time <- function (path, end_date = Sys.Date ()) {
ctbs_main_all <- main_contributors (path, end_date = end_date, period = NULL)
ctbs_main <- unique (c (ctbs_main_recent, ctbs_main_all))

issues <- cm_data_issues_from_gh_api (path)
issues <- rm_data_issues_from_gh_api (path)
issues <- issues [grep ("issues", issues$url), ]
comments <- cm_data_issue_comments_from_gh_api (path)
comments <- rm_data_issue_comments_from_gh_api (path)

cmt_responses <- dplyr::filter (comments, user_login %in% ctbs_main) |>
dplyr::group_by (issue_number) |>
Expand Down Expand Up @@ -40,7 +40,7 @@ cm_metric_issue_response_time <- function (path, end_date = Sys.Date ()) {

cm_metric_defect_resolution_dur <- function (path, end_date = Sys.Date ()) {

issues <- cm_data_issues_from_gh_api (path)
issues <- rm_data_issues_from_gh_api (path)
index <- grep ("bug|defect|fix", issues$label, ignore.case = TRUE)
index <- index [which (!grepl ("wontfix", issues$label [index]))]
bugs <- issues [index, ]
Expand Down Expand Up @@ -113,7 +113,7 @@ cm_metric_pr_closure_ratio <- function (path, end_date = Sys.Date ()) {
# suppress no visible binding notes:
closed <- NULL

prs <- cm_data_prs_from_gh_api (path)
prs <- rm_data_prs_from_gh_api (path)
prs$created_at <- as.Date (prs$created_at)
prs$closed_at <- as.Date (prs$closed_at)

Expand All @@ -136,7 +136,7 @@ cm_metric_issue_age <- function (path, end_date = Sys.Date ()) {

start_date <- end_date - get_repometrics_period ()

issues <- cm_data_issues_from_gh_api (path) |>
issues <- rm_data_issues_from_gh_api (path) |>
dplyr::mutate (
created_at = as.Date (created_at), closed_at = as.Date (closed_at)
) |>
Expand Down
10 changes: 5 additions & 5 deletions R/cm-data-dependencies.R → R/data-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param path Local path to repository
#' @noRd
cm_data_dependencies <- function (path) {
rm_data_dependencies <- function (path) {

desc_path <- fs::dir_ls (path, type = "file", regexp = "DESCRIPTION$")
checkmate::assert_file_exists (desc_path)
Expand Down Expand Up @@ -32,7 +32,7 @@ cm_data_dependencies <- function (path) {
#'
#' Note that this all works even for packages which aren't on CRAN.
#' @noRd
cm_data_dependencies_downstream <- function (path) {
rm_data_dependencies_downstream <- function (path) {

cran_db <- cran_pkg_db ()
pkg_name <- pkg_name_from_path (path)
Expand All @@ -52,16 +52,16 @@ cm_data_dependencies_downstream <- function (path) {
#'
#' @param path Local path to repository
#' @noRd
cm_data_libyears <- function (path) {
rm_data_libyears <- function (path) {

deps <- cm_data_dependencies (path)
deps <- rm_data_dependencies (path)
cran_db <- data.frame (cran_pkg_db ())
index <- match (deps$name, cran_db$Package)
deps$cran_version <- cran_db$Version [index]
deps$published <- as.Date (cran_db$Published [index])
deps <- deps [which (!is.na (deps$published)), ]

rel <- cm_data_releases_from_gh_api (path, latest_only = TRUE)
rel <- rm_data_releases_from_gh_api (path, latest_only = TRUE)
rel_date <- as.Date (strftime (rel$published_at, format = "%Y-%m-%d"))

dt <- difftime (deps$published, rel_date, units = "days")
Expand Down
14 changes: 7 additions & 7 deletions R/cm-data-gh-contribs.R → R/data-gh-contribs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#'
#' @param path Local path to repository
#' @noRd
cm_data_contribs_from_log <- function (path) {
rm_data_contribs_from_log <- function (path) {

log <- cm_data_gitlog (path)
log <- rm_data_gitlog (path)

gh_handle <- unique (log$aut_name)
gh_email <- log$aut_email [match (gh_handle, log$aut_name)]
Expand Down Expand Up @@ -40,7 +40,7 @@ cm_data_contribs_from_log <- function (path) {
#' @param n_per_page Not used here, but needed so all functions can safely be
#' called with this parameter.
#' @noRd
cm_data_contribs_from_gh_api_internal <- function (path, n_per_page = 100L) {
rm_data_contribs_from_gh_api_internal <- function (path, n_per_page = 100L) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
n_per_page <- n_per_page_in_tests (n_per_page)
Expand Down Expand Up @@ -94,8 +94,8 @@ cm_data_contribs_from_gh_api_internal <- function (path, n_per_page = 100L) {

return (ctbs)
}
cm_data_contribs_from_gh_api <-
memoise::memoise (cm_data_contribs_from_gh_api_internal)
rm_data_contribs_from_gh_api <-
memoise::memoise (rm_data_contribs_from_gh_api_internal)

user_from_gh_api <- function (user) {

Expand Down Expand Up @@ -134,9 +134,9 @@ main_contributors <- function (path, end_date = Sys.Date (), threshold = 0.9, pe
checkmate::assert_integerish (period, min = 1L)
log <- git_log_in_period (path, end_date = end_date, period = period)
} else {
log <- cm_data_gitlog (path)
log <- rm_data_gitlog (path)
}
contribs <- cm_data_contribs_from_gh_api (path)
contribs <- rm_data_contribs_from_gh_api (path)

index <- match (log$aut_email, contribs$email)
log$login <- contribs$login [index]
Expand Down
4 changes: 2 additions & 2 deletions R/cm-data-gh-forks.R → R/data-gh-forks.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gh_forks_qry <- function (org = "ropensci-review-tools",
return (q)
}

cm_data_repo_forks_internal <- function (path, n_per_page = 100L) {
rm_data_repo_forks_internal <- function (path, n_per_page = 100L) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
n_per_page <- n_per_page_in_tests (n_per_page)
Expand Down Expand Up @@ -65,4 +65,4 @@ cm_data_repo_forks_internal <- function (path, n_per_page = 100L) {
created = as.Date (created)
)
}
cm_data_repo_forks <- memoise::memoise (cm_data_repo_forks_internal)
rm_data_repo_forks <- memoise::memoise (rm_data_repo_forks_internal)
12 changes: 6 additions & 6 deletions R/cm-data-gh-issues.R → R/data-gh-issues.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cm_data_issues_from_gh_api_internal <- function (path, n_per_page = 100) {
rm_data_issues_from_gh_api_internal <- function (path, n_per_page = 100) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
n_per_page <- n_per_page_in_tests (n_per_page)
Expand Down Expand Up @@ -75,8 +75,8 @@ cm_data_issues_from_gh_api_internal <- function (path, n_per_page = 100) {

return (issues)
}
cm_data_issues_from_gh_api <-
memoise::memoise (cm_data_issues_from_gh_api_internal)
rm_data_issues_from_gh_api <-
memoise::memoise (rm_data_issues_from_gh_api_internal)

get_issue_reactions <- function (body) {

Expand All @@ -95,7 +95,7 @@ get_issue_reactions <- function (body) {
return (reaction_counts)
}

cm_data_issue_comments_from_gh_api_internal <- function (path,
rm_data_issue_comments_from_gh_api_internal <- function (path,
n_per_page = 100) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
Expand Down Expand Up @@ -148,5 +148,5 @@ cm_data_issue_comments_from_gh_api_internal <- function (path,
issue_body = issue_body
)
}
cm_data_issue_comments_from_gh_api <-
memoise::memoise (cm_data_issue_comments_from_gh_api_internal)
rm_data_issue_comments_from_gh_api <-
memoise::memoise (rm_data_issue_comments_from_gh_api_internal)
4 changes: 2 additions & 2 deletions R/cm-data-gh-prs.R → R/data-gh-prs.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ gh_prs_qry <- function (org = "ropensci-review-tools",
return (q)
}

cm_data_prs_from_gh_api_internal <- function (path, n_per_page = 30L) {
rm_data_prs_from_gh_api_internal <- function (path, n_per_page = 30L) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
n_per_page <- n_per_page_in_tests (n_per_page)
Expand Down Expand Up @@ -273,4 +273,4 @@ cm_data_prs_from_gh_api_internal <- function (path, n_per_page = 30L) {
reviews = I (reviews)
)
}
cm_data_prs_from_gh_api <- memoise::memoise (cm_data_prs_from_gh_api_internal)
rm_data_prs_from_gh_api <- memoise::memoise (rm_data_prs_from_gh_api_internal)
6 changes: 3 additions & 3 deletions R/cm-data-gh-releases.R → R/data-gh-releases.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cm_data_releases_from_gh_api_internal <- function (path,
rm_data_releases_from_gh_api_internal <- function (path,
n_per_page = 100L,
latest_only = FALSE) {

Expand Down Expand Up @@ -53,5 +53,5 @@ cm_data_releases_from_gh_api_internal <- function (path,
vapply (body, function (i) i$published_at, character (1L))
)
}
cm_data_releases_from_gh_api <-
memoise::memoise (cm_data_releases_from_gh_api_internal)
rm_data_releases_from_gh_api <-
memoise::memoise (rm_data_releases_from_gh_api_internal)
4 changes: 2 additions & 2 deletions R/cm-data-gh-repo.R → R/data-gh-repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param path Local path to repository
#' @noRd
cm_data_repo_from_gh_api_internal <- function (path) {
rm_data_repo_from_gh_api_internal <- function (path) {

or <- org_repo_from_path (path)

Expand Down Expand Up @@ -40,4 +40,4 @@ cm_data_repo_from_gh_api_internal <- function (path) {
default_branch = null2na_char (body$default_branch)
)
}
cm_data_repo_from_gh_api <- memoise::memoise (cm_data_repo_from_gh_api_internal)
rm_data_repo_from_gh_api <- memoise::memoise (rm_data_repo_from_gh_api_internal)
4 changes: 2 additions & 2 deletions R/cm-data-gh-stargazers.R → R/data-gh-stargazers.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gh_stargazers_qry <- function (org = "ropensci-review-tools",
return (q)
}

cm_data_repo_stargazers_internal <- function (path, n_per_page = 100L) {
rm_data_repo_stargazers_internal <- function (path, n_per_page = 100L) {

is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
n_per_page <- n_per_page_in_tests (n_per_page)
Expand Down Expand Up @@ -66,4 +66,4 @@ cm_data_repo_stargazers_internal <- function (path, n_per_page = 100L) {
starred_at = as.Date (starred_at)
)
}
cm_data_repo_stargazers <- memoise::memoise (cm_data_repo_stargazers_internal)
rm_data_repo_stargazers <- memoise::memoise (rm_data_repo_stargazers_internal)
Loading

0 comments on commit cc6a3ef

Please sign in to comment.