bugfixes for empty comments and empty logs
This commit is contained in:
@@ -68,12 +68,16 @@ generate.admin.addrm <- function (logevents, current.admins) {
|
||||
# another function to handle processing the ancients:
|
||||
parse.ancient <- function (i, d) {
|
||||
user <- sub('^.*?:', '', d[i,"title"])
|
||||
comment <- d[i, "comment"]
|
||||
log.comment <- d[i, "comment"]
|
||||
change.time <- d[i, "timestamp"]
|
||||
|
||||
added <- unlist(strsplit(unlist(strsplit(comment, '(\\+|\\=)')), ', '))
|
||||
log.comment <- as.character(log.comment)
|
||||
added <- unlist(strsplit(unlist(strsplit(log.comment, '(\\+|\\=)')), ', '))
|
||||
|
||||
# clean any leadin, trailing whitespace
|
||||
if(is.null(added)){
|
||||
added <- ''
|
||||
}
|
||||
## clean any leadin, trailing whitespace
|
||||
added <- gsub("^\\s+|\\s+$", "", added)
|
||||
|
||||
data.frame(user=user,
|
||||
@@ -109,9 +113,14 @@ generate.admin.addrm <- function (logevents, current.admins) {
|
||||
return(o)
|
||||
}
|
||||
|
||||
if(dim(current.admins)[1] > 0){
|
||||
current.admins.parsed <- do.call("rbind",
|
||||
lapply(1:dim(current.admins)[1],
|
||||
parse.current.admins, current.admins))
|
||||
}
|
||||
else {
|
||||
current.admins.parsed <- data.frame(user=character(),role=character())
|
||||
}
|
||||
|
||||
# select pre-ancients as people who have a given right *today* but
|
||||
# were never seen as having it added
|
||||
@@ -155,10 +164,12 @@ generate.admin.addrm <- function (logevents, current.admins) {
|
||||
|
||||
pre.ancients <- rbind(pre.ancients, combined.removed)
|
||||
|
||||
# give them the earliest ancient timestamp minus 1 day
|
||||
if(nrow(pre.ancients) > 0){
|
||||
## give them the earliest ancient timestamp minus 1 day
|
||||
pre.ancients$action <- "added"
|
||||
pre.ancients$timestamp <- as.POSIXct("2000-01-01 00:00:00") # min(combined$timestamp) - 60 * 1440
|
||||
pre.ancients$era <- "pre.ancient"
|
||||
}
|
||||
|
||||
# and then add the pre.ancients to the
|
||||
combined <- rbind(combined, pre.ancients)
|
||||
|
||||
Reference in New Issue
Block a user