Bearloga has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/382491 )

Change subject: Switch to fetching EL data from db1047
......................................................................


Switch to fetching EL data from db1047

Bug: T176639
Change-Id: If27580cc76f9d3aa3439e2aef728d76fabc46a6f
---
M DESCRIPTION
M NEWS.md
M R/mysql.R
M man/mysql.Rd
4 files changed, 34 insertions(+), 14 deletions(-)

Approvals:
  Bearloga: Verified; Looks good to me, approved



diff --git a/DESCRIPTION b/DESCRIPTION
index b8fe3d1..68167a9 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: wmf
 Type: Package
 Title: R Code for Wikimedia Foundation Internal Usage
-Version: 0.2.6
-Date: 2017-01-23
+Version: 0.2.7
+Date: 2017-10-05
 Authors@R: c(
   person("Oliver", "Keyes", role = "aut"),
   person("Mikhail", "Popov", email = "[email protected]", role = c("aut", 
"cre")))
diff --git a/NEWS.md b/NEWS.md
index a414f5d..a7c627f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,10 @@
+wmf 0.2.7
+=========
+* Changes which host MySQL functions connect to, depending on the database:
+  - "db1047.eqiad.wmnet" for event logging data from "log" db
+  - "analytics-store.eqiad.wmnet" (same as before) for wiki content
+* See [T176639](https://phabricator.wikimedia.org/T176639) for more details.
+
 wmf 0.2.6
 =========
 * Adds support for more MySQL config filenames since those vary between the 
different machines
diff --git a/R/mysql.R b/R/mysql.R
index 0d47e46..e0ecd89 100644
--- a/R/mysql.R
+++ b/R/mysql.R
@@ -20,7 +20,9 @@
 #'@param query A SQL query.
 #'
 #'@param database The name of the database to query.
-#'
+#'@param hostname The name of the machine to connect to, which depends on
+#'  whether you want to fetch event logging data (from **db1047**) or wiki
+#'  content data (from **analytics-store**)
 #'@param con A MySQL connection returned by \code{mysql_connect}.
 #'  Optional -- if not provided, a temporary connection will be opened up.
 #'
@@ -36,11 +38,14 @@
 #'@seealso \code{\link{hive_query}} or \code{\link{global_query}}
 #'
 #'@export
-mysql_connect <- function(database, default_file = NULL) {
+mysql_connect <- function(
+  database, default_file = NULL,
+  hostname = ifelse(database == "log", "db1047.eqiad.wmnet", 
"analytics-store.eqiad.wmnet")
+) {
   if (is.null(default_file)) {
     possible_cnfs <- c(
-      "analytics-research-client.cnf", # on stat1002
-      "stats-research-client.cnf", # on stat1003
+      "analytics-research-client.cnf", # on stat1005
+      "stats-research-client.cnf", # on stat1006 and also on stat1005
       "research-client.cnf" # on notebook1001
     )
     for (cnf in file.path("/etc/mysql/conf.d", possible_cnfs)) {
@@ -64,13 +69,16 @@
     }
   }
   if (RMySQL_version() > 93) {
-    con <- dbConnect(drv = RMySQL::MySQL(),
-                     host = "analytics-store.eqiad.wmnet",
-                     dbname = database, default.file = default_file)
-  } else { # Using version RMySQL 0.9.3 or older:
-    con <- dbConnect(drv = "MySQL",
-                     host = "analytics-store.eqiad.wmnet",
-                     dbname = database, default.file = default_file)
+    con <- dbConnect(
+      drv = RMySQL::MySQL(), host = host_name,
+      dbname = database, default.file = default_file
+    )
+  } else {
+    # Using version RMySQL 0.9.3 or older:
+    con <- dbConnect(
+      drv = "MySQL", host = host_name,
+      dbname = database, default.file = default_file
+    )
   }
   return(con)
 }
diff --git a/man/mysql.Rd b/man/mysql.Rd
index a7913dc..deb2e41 100644
--- a/man/mysql.Rd
+++ b/man/mysql.Rd
@@ -10,7 +10,8 @@
 \alias{mysql_disconnect}
 \title{Work with MySQL databases}
 \usage{
-mysql_connect(database, default_file = NULL)
+mysql_connect(database, default_file = NULL, hostname = ifelse(database ==
+  "log", "db1047.eqiad.wmnet", "analytics-store.eqiad.wmnet"))
 
 mysql_read(query, database, con = NULL)
 
@@ -25,6 +26,10 @@
 \arguments{
 \item{database}{The name of the database to query.}
 
+\item{hostname}{The name of the machine to connect to, which depends on
+whether you want to fetch event logging data (from **db1047**) or wiki
+content data (from **analytics-store**)}
+
 \item{query}{A SQL query.}
 
 \item{con}{A MySQL connection returned by \code{mysql_connect}.

-- 
To view, visit https://gerrit.wikimedia.org/r/382491
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If27580cc76f9d3aa3439e2aef728d76fabc46a6f
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/wmf
Gerrit-Branch: master
Gerrit-Owner: Bearloga <[email protected]>
Gerrit-Reviewer: Bearloga <[email protected]>
Gerrit-Reviewer: Chelsyx <[email protected]>
Gerrit-Reviewer: Mforns <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to