Tim Starling has uploaded a new change for review.

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

Change subject: Edit count for 2015 elections
......................................................................

Edit count for 2015 elections

Change-Id: I65dcbc14e0a58e70a6764d7cf847cfb57e94ae60
---
A cli/wm-scripts/bv2015/bv2015_tables.sql
A cli/wm-scripts/bv2015/populateEditCount.php
2 files changed, 62 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll 
refs/changes/39/206739/1

diff --git a/cli/wm-scripts/bv2015/bv2015_tables.sql 
b/cli/wm-scripts/bv2015/bv2015_tables.sql
new file mode 100644
index 0000000..1dabe63
--- /dev/null
+++ b/cli/wm-scripts/bv2015/bv2015_tables.sql
@@ -0,0 +1,5 @@
+CREATE TABLE bv2015_edits (
+       bv_user int not null primary key,
+       bv_long_edits int not null,
+       bv_short_edits int not null
+);
diff --git a/cli/wm-scripts/bv2015/populateEditCount.php 
b/cli/wm-scripts/bv2015/populateEditCount.php
new file mode 100644
index 0000000..8ff8f46
--- /dev/null
+++ b/cli/wm-scripts/bv2015/populateEditCount.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * have made at least 300 edits before 15 April 2015 across Wikimedia wikis
+ * (edits on several wikis can be combined if your accounts are unified into a 
global account); and
+ * have made at least 20 edits between 15 October 2014 and 15 April 2015.
+ */
+
+require( dirname(__FILE__) . '/../../cli.inc' );
+
+$dbr = wfGetDB( DB_SLAVE );
+$dbw = wfGetDB( DB_MASTER );
+
+$maxUser = $dbr->selectField( 'user', 'MAX(user_id)', false );
+$beforeTime = '20150401500000';
+$betweenTime = array( '20141015000000', '20150415235959' );
+$fname = 'populateEditCount';
+
+$numUsers = 0;
+
+for ( $userId = 1; $userId <= $maxUser; $userId++ ) {
+       $exists = $dbr->selectField( 'user', '1', array( 'user_id' => $userId ) 
);
+       if ( !$exists ) {
+               continue;
+       }
+
+       $longEdits = $dbr->selectField( 'revision', 'COUNT(*)',
+               array(
+                       'rev_user' => $userId,
+                       'rev_timestamp < ' . $dbr->addQuotes( $beforeTime )
+               ), $fname
+       );
+
+       $shortEdits = $dbr->selectField( 'revision', 'COUNT(*)',
+               array(
+                       'rev_user' => $userId,
+                       'rev_timestamp BETWEEN ' . $dbr->addQuotes( 
$betweenTime[0] ) .
+                               ' AND ' . $dbr->addQuotes( $betweenTime[1] )
+               ),
+               $fname
+       );
+
+       if ( $longEdits !== 0 || $shortEdits !== 0 ) {
+               $dbw->insert( 'bv2015_edits',
+                       array(
+                               'bv_user' => $userId,
+                               'bv_long_edits' => $longEdits,
+                               'bv_short_edits' => $shortEdits
+                       ),
+                       $fname
+               );
+               $numUsers++;
+       }
+}
+
+echo wfWikiID() . ": $numUsers users added\n";
+

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65dcbc14e0a58e70a6764d7cf847cfb57e94ae60
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: wmf/1.25wmf12
Gerrit-Owner: Tim Starling <[email protected]>

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

Reply via email to