Created
October 11, 2013 22:57
-
-
Save Ironholds/6943291 to your computer and use it in GitHub Desktop.
Thanks users on Wikipedia.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Read in config variables and associated packages. | |
| source("config.r") | |
| #Construct query function | |
| sql.fun <- function(query_statement){ | |
| #Open a connection | |
| con <- dbConnect(drv = "MySQL", | |
| username = analytics_user, | |
| password = analytics_pass, | |
| host = analytics_server, | |
| dbname = analytics_database) | |
| #Send the query | |
| QuerySend <- dbSendQuery(con, statement = query_statement) | |
| #Retrieve output of query | |
| output <- fetch(QuerySend, n = -1) | |
| #Kill connection | |
| dbDisconnect(con) | |
| #Return output | |
| return(output) | |
| } | |
| #Retrieve thanks data | |
| thanks_data <- sql.fun("SELECT log_user AS user, log_timestamp AS timestamp FROM logging WHERE log_type = 'thanks';") | |
| #Retrieve preference data, factoring in when thanks was first used/enabled | |
| user_preference <- sql.fun(paste(" | |
| SELECT up_user | |
| FROM user_properties WHERE up_user IN | |
| (SELECT DISTINCT(rev_user) | |
| FROM revision | |
| WHERE rev_timestamp >= '",min(thanks_data$timestamp),"' | |
| GROUP BY rev_user) | |
| AND up_property = 'vector-noexperiments';",sep = "")) | |
| #And so the result of "the number of users who have even edited since thanks became active, compared to the number who used the system" iiis.. | |
| ((nrow(user_preference))/(length(unique(thanks_data$user))+nrow(user_preference))*100) | |
| #7.120085 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment