Catrope has uploaded a new change for review.

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

Change subject: Use aliases with "damaging" in them so we can add other ones 
(e.g. "goodfaith")
......................................................................

Use aliases with "damaging" in them so we can add other ones (e.g. "goodfaith")

Change-Id: I2f5859c12da50bffab096d9ee9e6fc4bca6d52c4
---
M includes/Hooks.php
1 file changed, 30 insertions(+), 31 deletions(-)


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

diff --git a/includes/Hooks.php b/includes/Hooks.php
index ede2dfd..72cf720 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -132,28 +132,27 @@
                $threshold = self::getDamagingThreshold( $wgUser );
                $dbr = \wfGetDB( DB_REPLICA );
 
-               $tables[] = 'ores_model';
-               $tables[] = 'ores_classification';
+               $tables['ores_damaging_mdl'] = 'ores_model';
+               $tables['ores_damaging_cls'] = 'ores_classification';
 
-               $fields[] = 'oresc_probability';
+               $fields['ores_damaging_score'] = 
'ores_damaging_cls.oresc_probability';
                // Add user-based threshold
-               $fields[] = $dbr->addQuotes( $threshold ) . ' AS 
ores_threshold';
+               $fields['ores_damaging_threshold'] = $dbr->addQuotes( 
$threshold );
 
-               $join_conds['ores_model'] = [ 'LEFT JOIN', [
-                       'oresm_is_current' => 1,
-                       'oresm_name' => 'damaging'
+               $join_conds['ores_damaging_mdl'] = [ 'LEFT JOIN', [
+                       'ores_damaging_mdl.oresm_is_current' => 1,
+                       'ores_damaging_mdl.oresm_name' => 'damaging'
                ] ];
-               $join_conds['ores_classification'] = [ 'LEFT JOIN', [
-                       'oresc_model = oresm_id',
-                       'rc_this_oldid = oresc_rev',
-                       'oresc_class' => 1
+               $join_conds['ores_damaging_cls'] = [ 'LEFT JOIN', [
+                       'ores_damaging_cls.oresc_model = 
ores_damaging_mdl.oresm_id',
+                       'rc_this_oldid = ores_damaging_cls.oresc_rev',
+                       'ores_damaging_cls.oresc_class' => 1
                ] ];
 
 
                if ( self::isModelEnabled( 'damaging' ) && $opts->getValue( 
'hidenondamaging' ) ) {
-
                        // Filter out non-damaging edits.
-                       $conds[] = 'oresc_probability > '
+                       $conds[] = 'ores_damaging_cls.oresc_probability > '
                                . $dbr->addQuotes( $threshold );
                        $conds['rc_patrolled'] = 0;
                        $query_options[] = 'STRAIGHT_JOIN';
@@ -250,27 +249,27 @@
                $threshold = self::getDamagingThreshold( $pager->getUser() );
                $dbr = \wfGetDB( DB_REPLICA );
 
-               $query['tables'][] = 'ores_model';
-               $query['tables'][] = 'ores_classification';
+               $query['tables']['ores_damaging_mdl'] = 'ores_model';
+               $query['tables']['ores_damaging_cls'] = 'ores_classification';
 
-               $query['fields'][] = 'oresc_probability';
+               $query['fields']['ores_damaging_score'] = 
'ores_damaging_cls.oresc_probability';
                // Add user-based threshold
-               $query['fields'][] = $dbr->addQuotes( $threshold ) . ' AS 
ores_threshold';
+               $query['fields']['ores_damaging_threshold'] = $dbr->addQuotes( 
$threshold );
 
-               $query['join_conds']['ores_model'] = [ 'LEFT JOIN', [
-                       'oresm_is_current' => 1,
-                       'oresm_name' => 'damaging',
+               $query['join_conds']['ores_damaging_mdl'] = [ 'LEFT JOIN', [
+                       'ores_damaging_mdl.oresm_is_current' => 1,
+                       'ores_damaging_mdl.oresm_name' => 'damaging',
                ] ];
 
-               $query['join_conds']['ores_classification'] = [ 'LEFT JOIN', [
-                       'oresc_model = oresm_id',
-                       'rev_id = oresc_rev',
-                       'oresc_class' => 1
+               $query['join_conds']['ores_damaging_cls'] = [ 'LEFT JOIN', [
+                       'ores_damaging_cls.oresc_model = 
ores_damaging_mdl.oresm_id',
+                       'rev_id = ores_damaging_cls.oresc_rev',
+                       'ores_damaging_cls.oresc_class' => 1
                ] ];
 
                if ( self::isModelEnabled( 'damaging' ) && 
$pager->getContext()->getRequest()->getVal( 'hidenondamaging' ) ) {
                        // Filter out non-damaging edits.
-                       $query['conds'][] = 'oresc_probability > '
+                       $query['conds'][] = 
'ores_damaging_cls.oresc_probability > '
                                . $dbr->addQuotes( $threshold );
                }
        }
@@ -283,11 +282,11 @@
                }
 
                // Doesn't have ores score, skipping.
-               if ( !isset( $row->oresc_probability ) ) {
+               if ( !isset( $row->ores_damaging_score ) ) {
                        return true;
                }
 
-               if ( $row->oresc_probability > $row->ores_threshold ) {
+               if ( $row->ores_damaging_score > $row->ores_damaging_threshold 
) {
                        // Prepend the "r" flag
                        array_unshift( $flags, ChangesList::flag( 'damaging' ) 
);
                }
@@ -301,11 +300,11 @@
                }
 
                // Doesn't have ores score, skipping.
-               if ( !isset( $row->oresc_probability ) ) {
+               if ( !isset( $row->ores_damaging_score ) ) {
                        return true;
                }
 
-               if ( $row->oresc_probability > $row->ores_threshold ) {
+               if ( $row->ores_damaging_score > $row->ores_damaging_threshold 
) {
                        // Add the damaging class
                        $classes[] = 'damaging';
                }
@@ -358,11 +357,11 @@
         */
        public static function getScoreRecentChangesList( $rcObj ) {
                global $wgUser;
-               $threshold = $rcObj->getAttribute( 'ores_threshold' );
+               $threshold = $rcObj->getAttribute( 'ores_damaging_threshold' );
                if ( $threshold === null ) {
                        $threshold = self::getDamagingThreshold( $wgUser );
                }
-               $score = $rcObj->getAttribute( 'oresc_probability' );
+               $score = $rcObj->getAttribute( 'ores_damaging_score' );
                $patrolled = $rcObj->getAttribute( 'rc_patrolled' );
 
                return $score && $score >= $threshold && !$patrolled;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f5859c12da50bffab096d9ee9e6fc4bca6d52c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>

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

Reply via email to