Skip to content

Commit

Permalink
Add check to get.first.activity.data to look for missing activity types
Browse files Browse the repository at this point in the history
Adresses issue se-sic#217

Signed-off-by: Niklas Schneider <s8nlschn@stud.uni-saarland.de>
  • Loading branch information
nlschn committed Feb 2, 2022
1 parent 4eec43c commit 1da2fbd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions util-networks-covariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,26 @@ get.first.activity.data = function(range.data, activity.types = c("commits", "ma
return(minima.per.person)
})

## if activity.by.type is null, print a warning and return an empty list
if (is.null(activity.by.type)) {
logging::logwarn('There were no activities in the given RangeData')
return(list())
}

## for each missing activity type add it with together with a copy of
## any other key but with the author lists set to NA;
## additionally, print a warning
missing.keys = setdiff(names(activity.by.type), activity.types)
present.key = intersect(names(activity.by.type), activity.types)[[1]]
na.list = lapply(activity.by.type[present.key], function (x) NA)

for (missing.key in missing.keys) {
logging::logwarn(paste(c('The type', missing.key, 'was configured',
'but the RangeData did not cotain any',
'activities of that type'), sep = ' '))
activity.by.type[missing.key] = na.list
}

## accumulate/fold lists 'activity.by.type' by adding all values of each list
## to an intermediate list (start with first list); for example:
## list(
Expand Down

0 comments on commit 1da2fbd

Please sign in to comment.