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

update workflow and report #2

Merged
merged 3 commits into from
Mar 23, 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
8 changes: 6 additions & 2 deletions .github/workflows/test-targets-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
test-targets-workflow:
runs-on: ubuntu-latest
container: rocker/tidyverse:4.2.2
container: rocker/tidyverse:4.2.3
env:
GIT_CRYPT_KEY64: ${{ secrets.GIT_CRYPT_KEY64 }}
GITHUB_PAT: ${{ secrets.GH_PAT }}
Expand Down Expand Up @@ -42,7 +42,11 @@ jobs:

- name: Run workflow
run: |
targets::tar_make()
targets::tar_make(dplyr::starts_with("ihtm"))
shell: Rscript {0}

- name: Deploy report
run: |
targets::tar_make(rrr_evaluation_report_html_2023)
shell: Rscript {0}

68 changes: 58 additions & 10 deletions R/calculate_commit_metrics.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@

################################################################################
#
#'
#' Calculate various GitHub commits metrics
#'
#' @param commits A data.frame/tibble of commits from specified Oxford IHTM
#' repositories participated in by students generated from the `get_commits()`
#' functions
#' @param start_date A date value specifying the starting date from which to
#' calculate the number of commits per day. Default is 2022-01-01
#'
#' @return A data.frame/tibble of number of commits by day, by person or by
#' person by day
#'
#' @rdname calculate_commits
#'
#
################################################################################

calculate_commits_per_day <- function(commits) {
commits |>
Expand All @@ -11,7 +28,11 @@ calculate_commits_per_day <- function(commits) {
) |>
dplyr::group_by(commit_date) |>
dplyr::count() |>
dplyr::ungroup()
dplyr::ungroup() |>
dplyr::mutate(
ihtm_class = paste0("class-", lubridate::year(commit_date)),
.before = commit_date
)
}


Expand All @@ -31,11 +52,14 @@ calculate_commits_per_week <- function(commits) {
) |>
dplyr::group_by(commit_week) |>
dplyr::count() |>
dplyr::ungroup()
dplyr::ungroup() |>
dplyr::mutate(
ihtm_class = paste0("class-", lubridate::year(as.Date(commit_week))),
.before = commit_week
)
}


calculate_commits_per_author <- function(commits) {
calculate_commits_per_author <- function(commits, class_list) {
commits |>
dplyr::select(
commit.author.name, author.id, author.login,
Expand All @@ -54,10 +78,18 @@ calculate_commits_per_author <- function(commits) {
username = unique(username),
n = n(),
.groups = "drop"
)
) |>
dplyr::right_join(
y = class_list |>
subset(select = c(login, id, ihtm_class)),
by = c("username" = "login", "author_id" = "id")
) |>
dplyr::relocate(ihtm_class, .before = author_id) |>
dplyr::arrange(ihtm_class, username) |>
dplyr::rename(id = author_id)
}

calculate_commits_per_author_per_day <- function(commits) {
calculate_commits_per_author_per_day <- function(commits, class_list) {
commits |>
dplyr::select(
commit.author.date, commit.author.name, author.id, author.login,
Expand All @@ -78,11 +110,19 @@ calculate_commits_per_author_per_day <- function(commits) {
username = unique(username),
n = n(),
.groups = "drop"
)
) |>
dplyr::right_join(
y = class_list |>
subset(select = c(login, id, ihtm_class)),
by = c("username" = "login", "author_id" = "id")
) |>
dplyr::relocate(ihtm_class, .before = commit_date) |>
dplyr::rename(id = author_id) |>
dplyr::arrange(ihtm_class, commit_date, username)
}


calculate_commits_per_author_per_week <- function(commits) {
calculate_commits_per_author_per_week <- function(commits, class_list) {
commits |>
dplyr::select(
commit.author.date, commit.author.name, author.id, author.login,
Expand Down Expand Up @@ -110,6 +150,14 @@ calculate_commits_per_author_per_week <- function(commits) {
username = unique(username),
n = n(),
.groups = "drop"
)
) |>
dplyr::right_join(
y = class_list |>
subset(select = c(login, id, ihtm_class)),
by = c("username" = "login", "author_id" = "id")
) |>
dplyr::relocate(ihtm_class, .before = commit_week) |>
dplyr::rename(id = author_id) |>
dplyr::arrange(ihtm_class, commit_week, username)
}

Loading