Skip to content

Commit

Permalink
Add methods to add vertex attributes for mail/issue/pr count for issue
Browse files Browse the repository at this point in the history
…se-sic#188

Signed-off-by: Johannes Hostert <[email protected]>
  • Loading branch information
JoJoDeveloping committed Mar 23, 2021
1 parent 9f9150a commit 7260d62
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 2 deletions.
249 changes: 249 additions & 0 deletions util-networks-covariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,255 @@ add.vertex.attribute.commit.count.helper = function(list.of.networks, project.da
return(nets.with.attr)
}


## * Mail count ----------------------------------------------------------

#' Add mail-count attribute based on the total number of mails send where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "mail.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.mail.count = function(list.of.networks, project.data,
name = "mail.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.mail.count, "author.name"
)

return(nets.with.attr)
}
#' Add mail-count attribute based on the number of mail threads participated in where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "mail.thread.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.mail.thread.count = function(list.of.networks, project.data,
name = "mail.thread.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.mail.thread.count, "author.name"
)

return(nets.with.attr)
}

## * Issue count --------------------------------------------------------------

#' Add issues-count attribute based on the number of issues participated in where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "issues.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.issue.count = function(list.of.networks, project.data,
name = "issues.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.issues.count, "author.name"
)

return(nets.with.attr)
}

#' Add issues-count attribute based on the number of issues participated by commenting in where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "issues.count.by.commenting"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.issue.count.by.commenting = function(list.of.networks, project.data,
name = "issues.count.by.commenting",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.issues.commented.in.count, "author.name"
)

return(nets.with.attr)
}

#' Add issues-count attribute based on the number of issues participated by commenting in where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "issue.comment.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.issue.comment.count = function(list.of.networks, project.data,
name = "issue.comment.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.issue.comments.count, "author.name"
)

return(nets.with.attr)
}

## * Pull request count -------------------------------------------------------------

#' Add PR-count attribute based on the number of PR created where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "pull.request.creation.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.pull.request.creation.count = function(list.of.networks, project.data,
name = "pull.request.creation.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.pull.requests.created.count, "author.name"
)

return(nets.with.attr)
}

#' Add PR-count attribute based on the number of PRs participated in where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "mail.thread.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.pull.request.count = function(list.of.networks, project.data,
name = "pull.request.count",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.pull.requests.count, "author.name"
)

return(nets.with.attr)
}

#' Add PR-count attribute based on the number of PRs commits were added to where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "mail.thread.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.pull.request.count.by.commits = function(list.of.networks, project.data,
name = "pull.request.count.by.commits",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.pull.requests.commited.in.count, "author.name"
)

return(nets.with.attr)
}

#' Add PR-comment-count attribute based on the number of PRs comments written where the person represented by the vertex is the author
#'
#' @param list.of.networks The network list
#' @param project.data The project data
#' @param name The attribute name to add [default: "mail.thread.count"]
#' @param aggregation.level Determines the data to use for the attribute calculation.
#' One of \code{"range"}, \code{"cumulative"}, \code{"all.ranges"},
#' \code{"project.cumulative"}, \code{"project.all.ranges"}, and
#' \code{"complete"}. See \code{split.data.by.networks} for
#' more details. [default: "range"]
#' @param default.value The default value to add if a vertex has no matching value [default: 0L]
#'
#' @return A list of networks with the added attribute
add.vertex.attribute.pull.request.count.by.commits = function(list.of.networks, project.data,
name = "pull.request.comments",
aggregation.level = c("range", "cumulative", "all.ranges",
"project.cumulative", "project.all.ranges",
"complete"),
default.value = 0L) {
nets.with.attr = add.vertex.attribute.commit.count.helper(
list.of.networks, project.data, name, aggregation.level,
default.value, get.author.pull.request.comments.count, "author.name"
)

return(nets.with.attr)
}

## * Meta-data -------------------------------------------------------------

#' Add author email attribute
Expand Down
4 changes: 2 additions & 2 deletions util-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ split.data.time.based = function(project.data, time.period = "3 months", bins =
data = list(
commits = project.data$get.commits(),
mails = project.data$get.mails(),
issues = project.data$get.issues()
issues = project.data$get.issues.unfiltered()
)
split.data = names(data)
names(split.data) = split.data
Expand Down Expand Up @@ -237,7 +237,7 @@ split.data.activity.based = function(project.data, activity.type = c("commits",
data = list(
commits = project.data$get.commits(),
mails = project.data$get.mails(),
issues = project.data$get.issues()
issues = project.data$get.issues.unfiltered()
)

## define ID columns for mails and commits
Expand Down

0 comments on commit 7260d62

Please sign in to comment.