Ladsgroup has uploaded a new change for review.

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

Change subject: Add PopluateDatabase.php
......................................................................

Add PopluateDatabase.php

Bug: T123795
Change-Id: Ia10250e261ed2a16afa970cdf3e9c5e3105bb98d
---
A maintenance/PopluateDatabase.php
1 file changed, 47 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/74/268874/1

diff --git a/maintenance/PopluateDatabase.php b/maintenance/PopluateDatabase.php
new file mode 100644
index 0000000..5913d72
--- /dev/null
+++ b/maintenance/PopluateDatabase.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace ORES;
+
+use Maintenance;
+use Title;
+use JobQueueGroup;
+
+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
+       ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
+       : __DIR__ . '/../../../maintenance/Maintenance.php' );
+
+/**
+ * @ingroup Maintenance
+ */
+class PopulateDatabase extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+
+               $this->addDescription( 'Poplute the database' );
+               $this->addOption( 'number', 'Number of revisions to be scored', 
false, true, 'n' );
+
+       }
+
+       public function execute() {
+               $dbr = wfGetDb( DB_SLAVE );
+               $limit = $this->getOption('number', 1000);
+               $join_conds = array( 'ores_classification' =>
+                       array( 'LEFT JOIN', array('oresc_rev = rc_this_oldid') )
+               );
+               $res = $dbr->select( array( 'recentchanges', 
'ores_classification' ),
+                       array( 'rc_this_oldid', 'rc_title' ), array( 'oresc_id 
IS NULL', 'rc_type' => 0 ),
+                       __METHOD__, array( 'GROUP BY' => 'rc_this_oldid', 
'ORDER BY' => 'rc_id',
+                               'DESC', 'LIMIT' => $limit ), $join_conds );
+               foreach ( $res as $row ) {
+                       $title = Title::makeTitle(0, $row->rc_title);
+                       $job = new FetchScoreJob( $title, array(
+                               'revid' => $row->rc_this_oldid,
+                       ) );
+                       JobQueueGroup::singleton()->push( $job );
+               }
+               // @todo this script needs some output
+       }
+}
+
+$maintClass = 'ORES\PopulateDatabase';
+require_once RUN_MAINTENANCE_IF_MAIN;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia10250e261ed2a16afa970cdf3e9c5e3105bb98d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com>

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

Reply via email to