18
0

bugfixes for empty comments and empty logs

This commit is contained in:
2018-04-09 23:53:47 +00:00
parent f4a3e69c1c
commit 0b349fd5fb

View File

@@ -67,21 +67,25 @@ generate.admin.addrm <- function (logevents, current.admins) {
# another function to handle processing the ancients: # another function to handle processing the ancients:
parse.ancient <- function (i, d) { parse.ancient <- function (i, d) {
user <- sub('^.*?:', '', d[i,"title"]) user <- sub('^.*?:', '', d[i,"title"])
comment <- d[i, "comment"] log.comment <- d[i, "comment"]
change.time <- d[i, "timestamp"] 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 <- gsub("^\\s+|\\s+$", "", added) added <- ''
}
## clean any leadin, trailing whitespace
added <- gsub("^\\s+|\\s+$", "", added)
data.frame(user=user, data.frame(user=user,
role=added, role=added,
action="added", action="added",
timestamp=change.time, timestamp=change.time,
era="ancient", era="ancient",
stringsAsFactors=FALSE) stringsAsFactors=FALSE)
} }
# if there are any ancients, we parse them # if there are any ancients, we parse them
@@ -109,9 +113,14 @@ generate.admin.addrm <- function (logevents, current.admins) {
return(o) return(o)
} }
current.admins.parsed <- do.call("rbind", if(dim(current.admins)[1] > 0){
lapply(1:dim(current.admins)[1], current.admins.parsed <- do.call("rbind",
parse.current.admins, current.admins)) 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 # select pre-ancients as people who have a given right *today* but
# were never seen as having it added # 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) pre.ancients <- rbind(pre.ancients, combined.removed)
# give them the earliest ancient timestamp minus 1 day if(nrow(pre.ancients) > 0){
pre.ancients$action <- "added" ## give them the earliest ancient timestamp minus 1 day
pre.ancients$timestamp <- as.POSIXct("2000-01-01 00:00:00") # min(combined$timestamp) - 60 * 1440 pre.ancients$action <- "added"
pre.ancients$era <- "pre.ancient" 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 # and then add the pre.ancients to the
combined <- rbind(combined, pre.ancients) combined <- rbind(combined, pre.ancients)