Jalexander has uploaded a new change for review.

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

Change subject: Add SecurePoll arbcom list creator (mainspace only edits)
......................................................................

Add SecurePoll arbcom list creator (mainspace only edits)

* Old script written a year or so ago (by Reedy?)
* Accepts minedits required and date those edits should be by
* Creates a SecurePoll voter list only counting edits from mainspace

Bug: 73325
Change-Id: I6c2ddb60fdf3cb3ec19a334c4ba314c33a1a3a91
---
A cli/wm-scripts/arbcomlist.php
1 file changed, 70 insertions(+), 0 deletions(-)


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

diff --git a/cli/wm-scripts/arbcomlist.php b/cli/wm-scripts/arbcomlist.php
new file mode 100644
index 0000000..4cf6e29
--- /dev/null
+++ b/cli/wm-scripts/arbcomlist.php
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Like makeSimpleList.php except with edits limited to the main namespace
+ */
+
+$optionsWithArgs = array( 'before', 'edits' );
+require( dirname(__FILE__).'/../cli.inc' );
+
+$dbr = wfGetDB( DB_SLAVE );
+$dbw = wfGetDB( DB_MASTER );
+$fname = 'arbcomlist.php';
+$before = isset( $options['before'] ) ? $dbr->timestamp( strtotime( 
$options['before'] ) ) : false;
+$minEdits = isset( $options['edits'] ) ? intval( $options['edits'] ) : false;
+
+if ( !isset( $args[0] ) ) {
+       echo "Usage: php arbcomlist.php [--replace] [--before=<date>] 
[--edits=num] <name>\n";
+       exit( 1 );
+}
+$listName = $args[0];
+$startBatch = 0;
+$batchSize = 100;
+
+$listExists = $dbr->selectField( 'securepoll_lists', '1', 
+       array( 'li_name' => $listName ), $fname );
+if ( $listExists ) {
+       if ( isset( $options['replace'] ) ) {
+               echo "Deleting existing list...\n";
+               $dbw->delete( 'securepoll_lists', array( 'li_name' => $listName 
), $fname );
+       } else {
+               echo "Error: list exists. Use --replace to replace it.\n";
+               exit( 1 );
+       }
+}
+
+while ( true ) {
+       $res = $dbr->select( 'user', 'user_id',
+               array( 'user_id > ' . $dbr->addQuotes( $startBatch ) ),
+               $fname,
+               array( 'LIMIT' => $batchSize ) );
+
+       if ( !$res->numRows() ) {
+               break;
+       }
+
+       $insertBatch = array();
+       foreach ( $res as $row ) {
+               $startBatch = $userId = $row->user_id;
+               $insertRow = array( 'li_name' => $listName, 'li_member' => 
$userId );
+               if ( $minEdits === false ) {
+                       $insertBatch[] = $insertRow;
+                       continue;
+               }
+
+               # Count edits
+               $conds = array( 'rev_user' => $userId );
+               if ( $before !== false ) {
+                       $conds[] = 'rev_timestamp < ' . $dbr->addQuotes( 
$before );
+               }
+               $conds[] = 'page_id=rev_page';
+               $conds['page_namespace'] = 0;
+               $edits = $dbr->selectField( array( 'page', 'revision' ), 
'COUNT(*)', $conds, $fname );
+               if ( $edits >= $minEdits ) {
+                       $insertBatch[] = $insertRow;
+               }
+       }
+       if ( $insertBatch ) {
+               $dbw->insert( 'securepoll_lists', $insertBatch, $fname );
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c2ddb60fdf3cb3ec19a334c4ba314c33a1a3a91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Jalexander <[email protected]>

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

Reply via email to