-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add vertex attributes #67
Changes from all commits
3ca6063
cafa3ab
32944cb
fe2721c
0371351
39065fd
e3c6510
cd261ad
a8ca406
288c927
d7d8986
2549f2b
bca66be
efd9b2d
06ec950
df52ac7
8ae1abf
b9f0bd3
3e20fb2
9f53875
a002dfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
## (c) Claus Hunsen, 2017 | ||
## [email protected] | ||
|
||
## (c) Felix Prasse, 2017 | ||
## [email protected] | ||
|
||
context("Splitting functionality.") | ||
|
||
|
@@ -1454,3 +1455,54 @@ test_that("Check and correct duplicate range names during network activity-based | |
expect_identical(result, expected, info = "Removal of duplicate ranges.") | ||
|
||
}) | ||
|
||
|
||
## | ||
## Test splitting data by network names. | ||
## | ||
test_that("Test splitting data by networks", { | ||
## configuration and data objects | ||
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) | ||
proj.conf$update.value("artifact.filter.base", FALSE) | ||
net.conf = NetworkConf$new() | ||
net.conf$update.values(list(author.relation = "cochange", simplify = FALSE)) | ||
|
||
## retrieve project data and network builder | ||
project.data = ProjectData$new(proj.conf) | ||
|
||
## split data | ||
mybins = as.POSIXct(c("2016-07-12 15:00:00", "2016-07-12 16:00:00", "2016-07-12 16:05:00", "2030-01-01 00:00:00")) | ||
input.data = split.data.time.based(project.data, bins = mybins) | ||
input.data.network = lapply(input.data, function(d) NetworkBuilder$new(d, net.conf)$get.author.network()) | ||
|
||
aggregation.level = c("range", "cumulative", "project") | ||
## split data by networks | ||
results = lapply(aggregation.level, function(level) | ||
split.data.by.networks(input.data.network, project.data, level) | ||
) | ||
names(results) = aggregation.level | ||
|
||
expected.ranges = list("range" = c("2016-07-12 15:00:00-2016-07-12 16:00:00", | ||
"2016-07-12 16:00:00-2016-07-12 16:05:00", | ||
"2016-07-12 16:05:00-2030-01-01 00:00:00"), | ||
"cumulative" = c("1970-01-01 00:00:00-2016-07-12 16:00:00", | ||
"1970-01-01 00:00:00-2016-07-12 16:05:00", | ||
"1970-01-01 00:00:00-2030-01-01 00:00:00"), | ||
"project" = c("1970-01-01 00:00:00-9999-01-01 00:00:00", | ||
"1970-01-01 00:00:00-9999-01-01 00:00:00", | ||
"1970-01-01 00:00:00-9999-01-01 00:00:00")) | ||
|
||
test.each.network = function(aggregation.level) { | ||
result.data = results[[aggregation.level]] | ||
expected.range.names = expected.ranges[[aggregation.level]] | ||
|
||
lapply(seq_along(result.data), function(i) { | ||
result.entry = result.data[[i]] | ||
|
||
expect_true(igraph::identical_graphs(result.entry[["network"]], input.data.network[[i]])) | ||
expect_equal(result.entry[["data"]]$get.range(), expected.range.names[[i]]) | ||
}) | ||
} | ||
|
||
lapply(names(results), test.each.network) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
## [email protected] | ||
## (c) Sofie Kemper, 2017 | ||
## [email protected] | ||
## (c) Felix Prasse, 2017 | ||
## [email protected] | ||
|
||
## This file is derived from following Codeface script: | ||
## https://github.com/siemens/codeface/blob/master/codeface/R/developer_classification.r | ||
|
@@ -451,6 +453,50 @@ get.commit.count.threshold = function(range.data) { | |
return(threshold) | ||
} | ||
|
||
#' Get the commit count per comitter in the given range data | ||
#' | ||
#' @param range.data The data to count on | ||
#' @return A data frame in descending order by the commit count. | ||
get.committer.not.author.commit.count = function(range.data) { | ||
logging::logdebug("get.committer.not.author.commit.count: starting.") | ||
|
||
## Get commit data | ||
commits.df = get.commit.data(range.data, columns = c("committer.name", "author.name"))[[1]] | ||
|
||
## Return NA in case no commit data is available | ||
if(all(is.na(commits.df))) { | ||
return(NA) | ||
} | ||
|
||
## Execute a query to get the commit count per author | ||
res = sqldf::sqldf("SELECT *, COUNT(*) As `freq` FROM `commits.df` WHERE committer.name <> author.name GROUP BY `committer.name`,`author.name` ORDER BY `freq` DESC") | ||
|
||
logging::logdebug("get.committer.not.author.commit.count: finished.") | ||
return(res) | ||
} | ||
|
||
#' Get the commit count per comitter in the given range data | ||
#' | ||
#' @param range.data The data to count on | ||
#' @return A data frame in descending order by the commit count. | ||
get.committer.commit.count = function(range.data) { | ||
logging::logdebug("get.contributer.commit.count: starting.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the tracing comment to: |
||
|
||
## Get commit data | ||
commits.df = get.commit.data(range.data, columns = c("committer.name", "committer.email"))[[1]] | ||
|
||
## Return NA in case no commit data is available | ||
if(all(is.na(commits.df))) { | ||
return(NA) | ||
} | ||
|
||
## Execute a query to get the commit count per author | ||
res = sqldf::sqldf("select *, COUNT(*) as `freq` from `commits.df` group by `committer.name` order by `freq` desc") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should capitalize all SQL keywords as in the other |
||
|
||
logging::logdebug("get.author.commit.count: finished.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the tracing comment to: |
||
return(res) | ||
} | ||
|
||
## Get the commit count per author of the specified version range | ||
## as a data frame ordered by the commit count. | ||
get.author.commit.count = function(range.data) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the documentation here, we should state that we only count the commits of committers iff they are not the author.