jenkins-bot has submitted this change and it was merged.
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, 71 insertions(+), 0 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/cli/wm-scripts/arbcomlist.php b/cli/wm-scripts/arbcomlist.php
new file mode 100644
index 0000000..b128bd4
--- /dev/null
+++ b/cli/wm-scripts/arbcomlist.php
@@ -0,0 +1,71 @@
+<?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 );
+ wfWaitForSlaves();
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/172892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6c2ddb60fdf3cb3ec19a334c4ba314c33a1a3a91
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: wmf/1.25wmf7
Gerrit-Owner: Jalexander <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits