Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/260911

Change subject: Add script to track the use of catwatch feature
......................................................................

Add script to track the use of catwatch feature

This probably doesn't belong in this repo
but it can live here for now...

Bug: T119195
Change-Id: Ib575321a37b0d7f1f0d265f9049abe749b0efe11
---
M daily_misc.sh
A graphite/catwatch.php
2 files changed, 67 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/analytics/limn-wikidata-data 
refs/changes/11/260911/1

diff --git a/daily_misc.sh b/daily_misc.sh
index a9eef38..ec14f9f 100755
--- a/daily_misc.sh
+++ b/daily_misc.sh
@@ -3,3 +3,4 @@
 ~/wikidata-data/graphite/development/phabricator.php
 ~/wikidata-data/graphite/showcase.php
 ~/wikidata-data/graphite/hive/entitydata.php
+~/wikidata-data/graphite/catwatch.php
diff --git a/graphite/catwatch.php b/graphite/catwatch.php
new file mode 100644
index 0000000..eea2c2e
--- /dev/null
+++ b/graphite/catwatch.php
@@ -0,0 +1,66 @@
+#!/usr/bin/php
+<?php
+/**
+ * This does not actually relate to wikidata.
+ * This tracks the usage of the catwatch feature every day across all wikis.
+ *
+ * TODO FIXME this should probably live somewhere else?
+ * But it uses the WikimediaDb and WikimediaCurl classes. So we can just leave 
it here....
+ *
+ * @author Addshore
+ */
+
+require_once( __DIR__ . '/../src/WikimediaDb.php' );
+require_once( __DIR__ . '/../src/WikimediaCurl.php' );
+
+$dblist = WikimediaCurl::curlGet( 'https://noc.wikimedia.org/conf/all.dblist' 
);
+if( $dblist === false ) {
+       throw new RuntimeException( 'Failed to get db list for CatWatch 
tracking!' );
+}
+$dbs = explode( "\n", $dblist[1] );
+$dbs = array_filter( $dbs );
+
+$pdo = WikimediaDb::getPdo();
+
+$metrics = array();
+
+foreach( $dbs as $dbname ) {
+       $thisWikiHasSomeUse = false;
+       // Count each type of entity usage
+       $sql = "SELECT up_property AS settingAtZero, COUNT(up_user) AS users";
+       $sql .= "FROM $dbname.user_properties";
+       $sql .= "WHERE up_property IN ( 'hidecategorization', 
'watchlisthidecategorization' )";
+       $sql .= "AND up_value = 0";
+       $sql .= "GROUP BY up_property";
+       $queryResult = $pdo->query( $sql );
+
+       if( $queryResult === false ) {
+               echo "CatWatch DB query failed for $dbname, Skipping!!\n";
+       } else {
+
+               foreach( $queryResult as $row ) {
+                       if( $row['settingAtZero'] == 'hidecategorization' ) {
+                               if( $row['users'] > 0 ) {
+                                       $thisWikiHasSomeUse = true;
+                                       
$metrics['daily.catwatch.userprops.recentchanges.count'] += $row['users'];
+                               }
+                       } elseif( $row['settingAtZero'] == 
'watchlisthidecategorization ' ) {
+                               if( $row['users'] > 0 ) {
+                                       $thisWikiHasSomeUse = true;
+                                       
$metrics['daily.catwatch.userprops.watchlist.count'] += $row['users'];
+                               }
+                       }
+               }
+
+               if( $thisWikiHasSomeUse ) {
+                       $metrics['daily.catwatch.wikis.used'] += 1;
+               } else {
+                       $metrics['daily.catwatch.wikis.notused'] += 1;
+               }
+
+       }
+}
+
+foreach( $metrics as $metricName => $value ) {
+       exec( "echo \"$metricName $value `date +%s`\" | nc -q0 
graphite.eqiad.wmnet 2003" );
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib575321a37b0d7f1f0d265f9049abe749b0efe11
Gerrit-PatchSet: 1
Gerrit-Project: analytics/limn-wikidata-data
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to