Skip to content

Commit

Permalink
Fill GitHub's author names if empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Dec 4, 2024
1 parent 0e62cb8 commit 2f7bef0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/EngineGraphQLGitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ EngineGraphQLGitHub <- R6::R6Class(
.before = api_url
)
}
commits_table <- private$fill_empty_authors(commits_table)
return(commits_table)
},

Expand Down Expand Up @@ -539,6 +540,15 @@ EngineGraphQLGitHub <- R6::R6Class(
"files" = files
)
return(result)
},

fill_empty_authors = function(commits_table) {
commits_table <- commits_table |>
dplyr::rowwise() |>
dplyr::mutate(
author_name = ifelse(is.na(author_name) & is_name(author), author, author_name),
author_login = ifelse(is.na(author_login) & is_login(author), author, author_login)
)
}
)
)
10 changes: 10 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,13 @@ standardize_dates <- function(dates) {
url_encode <- function(url) {
URLencode(url, reserved = TRUE)
}

#' @noRd
is_name <- function(author) {
length(stringr::str_split_1(author, " ")) > 1
}

#' @noRd
is_login <- function(author) {
length(stringr::str_split_1(author, " ")) == 1 && identical(author, tolower(author))
}

0 comments on commit 2f7bef0

Please sign in to comment.