Awight has uploaded a new change for review.

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

Change subject: WIP Populate script
......................................................................

WIP Populate script

Change-Id: I83d06d62b50cc3702ec24f914de588e7e338f2cd
---
A maintenance/PopulateScores.php
1 file changed, 70 insertions(+), 0 deletions(-)


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

diff --git a/maintenance/PopulateScores.php b/maintenance/PopulateScores.php
new file mode 100644
index 0000000..3c0f350
--- /dev/null
+++ b/maintenance/PopulateScores.php
@@ -0,0 +1,70 @@
+<?php
+
+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
+       ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
+       : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
+
+/**
+ * @ingroup Maintenance
+ */
+class PopulateScores extends Maintenance {
+       /**
+        * @var string
+        */
+       protected $modelName;
+
+       /**
+        * @var integer
+        */
+       protected $modelVersion;
+
+       /**
+        * @var integer
+        */
+       protected $recentDays;
+
+       /**
+        * @var integer
+        */
+       protected $batchLimit;
+
+       public function __construct() {
+               parent::__construct();
+
+               $this->addDescription( 'Populate or update scores for a model.' 
);
+
+               $this->addOption( 'model', 'Model name', true, true );
+               $this->addOption( 'version', 'New model version', true, true );
+               $this->addOption( 'recentDays', 'Number of days into the past 
to rebuild', false, true );
+               $this->addOption( 'batchLimit', 'End batch after limit number 
of recent change scores is cached', false, true );
+       }
+
+       // TODO: parallelize
+       public function execute() {
+               const LOOP_SIZE = 50;
+
+               $this->modelName = $this->getOption( 'model' );
+               $this->modelVersion = $this->getOption( 'version' );
+               $this->recentDays = $this->getOption( 'recentDays', 30 );
+               $this->batchLimit = $this->getOption( 'batchLimit', 0 );
+
+               $count = 0;
+               #TODO $offset
+               while ( !$this->batchLimit || $count < $this->batchLimit ) {
+                       $changes = wfGetDB( DB_MASTER )->select( 
'recentchanges',
+                               'rc_id',
+                               array(
+                                       '(ores_rc IS NULL) OR 
+                               ),
+                               __METHOD__,
+                               array( 'ores_classification' => array( 'LEFT 
JOIN', 'ores_rc = rc_id' ) ),
+                               array(
+                                       'ORDER BY' => 'rc_id DESC',
+                               )
+                       );
+               }
+       }
+}
+
+$maintClass = 'PopulateScores';
+require_once RUN_MAINTENANCE_IF_MAIN;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I83d06d62b50cc3702ec24f914de588e7e338f2cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

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

Reply via email to