Skip to content

Instantly share code, notes, and snippets.

SELECT user.user_id,user.user_touched,user.user_registration, user.user_editcount,user_properties.up_value,user_rights.ur_rights,MAX(revision.rev_timestamp) FROM user_properties LEFT JOIN user ON user.user_id = user_properties.up_user LEFT JOIN user_rights ON user.user_id = user_rights.ur_user INNER JOIN revision ON user.user_id = revision.rev_user WHERE user_properties.up_property = 'gender' AND user.properties.up_value IS NOT NULL
mysql -u research -h db67.pmtpa.wmnet -p enwiki -e "SELECT
user.user_id,
MAX(revision.rev_timestamp),
user.user_touched,
user.user_registration,
user.user_editcount,
user_properties.up_value,
user_rights.ur_rights FROM
(((user_properties LEFT JOIN user ON user.user_id = user_properties.up_user) LEFT JOIN user_rights ON user.user_id = user_rights.ur_user) INNER JOIN revision ON user.user_id = revision.rev_user) WHERE user_properties.up_property = 'gender' AND user_properties.up_value IS NOT NULL" > gendergap.tsv
SELECT recentchanges.rc_user,
(CASE WHEN user_properties.up_value IN (1,'nostalgia') THEN 'nostalgia'
WHEN user_properties.up_value IN (2,'cologneblue') THEN 'cologneblue'
WHEN user_properties.up_value = 'myskin' THEN 'myskin'
WHEN user_properties.up_value = 'simple' THEN 'simple'
WHEN user_properties.up_value = 'standard' THEN 'standard'
WHEN user_properties.up_value = 'modern' THEN 'modern'
WHEN user_properties.up_value = 'monobook' THEN 'monobook'
WHEN user_properties.up_value = 'chick' THEN 'chick'
ELSE 'vector' END) AS skin
SELECT recentchanges.rc_user AS revs,
(CASE WHEN user_properties.up_value IN (1,'nostalgia') THEN 'nostalgia'
WHEN user_properties.up_value IN (2,'cologneblue') THEN 'cologneblue'
WHEN user_properties.up_value = 'myskin' THEN 'myskin'
WHEN user_properties.up_value = 'simple' THEN 'simple'
WHEN user_properties.up_value = 'standard' THEN 'standard'
WHEN user_properties.up_value = 'modern' THEN 'modern'
WHEN user_properties.up_value = 'monobook' THEN 'monobook'
WHEN user_properties.up_value = 'chick' THEN 'chick'
ELSE 'vector' END) AS skin
entropy.df <- subset(
tickets.df[
1:nrow(
tickets.df
)
%in% which(
outer(
subset(
tickets.df,
period == "hadean"
@Ironholds
Ironholds / Loose metric
Last active December 14, 2015 12:08
Loose metric. Running against the comments field from recentchanges, and it really /should/ be picking things up.
rc.df <- read.delim (file.path(getwd(), "Vpocalypse", "RecentChanges", "recentchanges.tsv"), header = TRUE, na.strings='NULL', as.is = TRUE, colClasses=c("user_editcount"="numeric"))
test <- grep(
pattern = "
(^revert\ to.+using)
| (^reverted\ edits\ by.+using)
| (^reverted\ edits\ by.+to\ last\ version\ by)
| (^bot\ -\ rv.+to\ last\ version\ by)
| (-assisted\ reversion)
| (^(revert(ed)?|rv).+to\ last)
data.fun <- function(db67p) {
if (exists("db67p"==TRUE){
dbh <- "MySQL"
db67 <- "db67.pmtpa.wmnet"
db67u <- "research"
db67db <- "enwiki"
return(dbh)
} else {
print("you need a password, jackass")
}
@Ironholds
Ironholds / gist:5750728
Created June 10, 2013 17:39
Borked query
SELECT
substring(revision.rev_timestamp,1,8) AS rev_timestamp,
revision.rev_comment AS reason,
revision.rev_sha1 as sha
FROM revision
WHERE revision.rev_timestamp > 20130609235959;
SELECT COUNT(
SELECT COUNT(*) AS edits,
substring(rev_timestamp,1,6) AS month,
rev_user AS user
FROM revision
WHERE rev_user > 0
GROUP BY substring(rev_timestamp,1,6),rev_user
HAVING edits >= 5)
GROUP BY month
#Data on registrations
registrations.fun <- function(x, graphname, filename){
#Aggregate
aggregate.data <- as.data.frame(
table(x$registration_date
)
)
#Plot registrations