Catrope has uploaded a new change for review.

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

Change subject: [WIP] Add goodfaith filtering
......................................................................

[WIP] Add goodfaith filtering

Need to figure out:
* Threshold setting
* Wording of interface messages

Bug: T137966
Change-Id: I266f6485051f41044f6219a330433737b365a55a
---
M i18n/en.json
M includes/Hooks.php
2 files changed, 72 insertions(+), 0 deletions(-)


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

diff --git a/i18n/en.json b/i18n/en.json
index 891d5b4..a395f6f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -11,8 +11,10 @@
        "ores-damaging-soft": "Low (flags fewer edits)",
        "ores-damaging-title": "This edit needs review",
        "ores-damaging-legend": "This edit may be damaging and should be 
reviewed ([[:mw:Special:MyLanguage/ORES review tool|more info]])",
+       "ores-goodfaith-filter": "$1 probably bad faith edits",
        "ores-help-damaging-pref": "This threshold determines how sensitive 
ORES is when flagging edits needing review",
        "ores-hide-nondamaging-filter": "Only show edits needing review",
+       "ores-hide-nongoodfaith-filter": "Only show probably good-faith edits",
        "ores-pref-damaging": "ORES sensitivity",
        "ores-pref-rc-hidenondamaging": "Hide probably good edits from recent 
changes",
        "ores-pref-watchlist-hidenondamaging": "Hide probably good edits from 
the watchlist",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 65744b3..cc66017 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -105,6 +105,13 @@
                        ];
                }
 
+               if ( self::isModelEnabled( 'goodfaith' ) ) {
+                       $filters['hidenongoodfaith'] = [
+                               'msg' => 'ores-goodfaith-filter',
+                               'default' => false
+                       ];
+               }
+
                return true;
        }
 
@@ -160,6 +167,31 @@
                        }
                }
 
+               if ( self::isModelEnabled( 'goodfaith' ) ) {
+                       $threshold = 0.93; // FIXME
+                       $tables['ores_goodfaith_mdl'] = 'ores_model';
+                       $tables['ores_goodfaith_cls'] = 'ores_classification';
+
+                       $fields['ores_goodfaith_score'] = 
'ores_goodfaith_cls.oresc_probability';
+                       $fields['ores_goodfaith_threshold'] = $dbr->addQuotes( 
$threshold );
+
+                       $join_conds['ores_goodfaith_mdl'] = [ 'LEFT JOIN', [
+                               'ores_goodfaith_mdl.oresm_is_current' => 1,
+                               'ores_goodfaith_mdl.oresm_name' => 'goodfaith'
+                       ] ];
+                       $join_conds['ores_goodfaith_cls'] = [ 'LEFT JOIN', [
+                               'ores_goodfaith_cls.oresc_model = 
ores_goodfaith_mdl.oresm_id',
+                               'rc_this_oldid = ores_goodfaith_cls.oresc_rev',
+                               'ores_goodfaith_cls.oresc_class' => 1
+                       ] ];
+
+                       if ( $opts->getValue( 'hidenongoodfaith' ) ) {
+                               // Filter out non-good faith edits
+                               $conds[] = 
'ores_goodfaith_cls.oresc_probability > ' .
+                                       $dbr->addQuotes( $threshold );
+                               $filtering = true;
+                       }
+               }
 
                if ( $filtering ) {
                        $conds['rc_patrolled'] = 0;
@@ -283,6 +315,30 @@
                        }
                }
 
+               if ( self::isModelEnabled( 'goodfaith' ) ) {
+                       $threshold = 0.93; // FIXME
+                       $query['tables']['ores_goodfaith_mdl'] = 'ores_model';
+                       $query['tables']['ores_goodfaith_cls'] = 
'ores_classification';
+
+                       $query['fields']['ores_goodfaith_score'] = 
'ores_goodfaith_cls.oresc_probability';
+                       $query['fields']['ores_goodfaith_threshold'] = 
$dbr->addQuotes( $threshold );
+
+                       $query['join_conds']['ores_goodfaith_mdl'] = [ 'LEFT 
JOIN', [
+                               'ores_goodfaith_mdl.oresm_is_current' => 1,
+                               'ores_goodfaith_mdl.oresm_name' => 'goodfaith',
+                       ] ];
+
+                       $query['join_conds']['ores_goodfaith_cls'] = [ 'LEFT 
JOIN', [
+                               'ores_goodfaith_cls.oresc_model = 
ores_goodfaith_mdl.oresm_id',
+                               'rev_id = ores_goodfaith_cls.oresc_rev',
+                               'ores_goodfaith_cls.oresc_class' => 1
+                       ] ];
+
+                       if ( $pager->getContext()->getRequest()->getVal( 
'hidenongoodfaith' ) ) {
+                               // Filter out non-goodfaith edits.
+                               $query['conds'][] = 
'ores_goodfaith_cls.oresc_probability > ' .
+                                       $dbr->addQuotes( $threshold );
+                       }
                }
        }
 
@@ -341,6 +397,20 @@
                        );
                }
 
+               if ( self::isModelEnabled( 'goodfaith' ) ) {
+                       $filters[] = Html::rawElement(
+                               'span',
+                               [ 'class' => 'mw-input-with-label' ],
+                               Xml::checkLabel(
+                                       $page->msg(' 
ores-hide-nongoodfaith-filter' )->text(),
+                                       'hidenongoodfaith',
+                                       'ores-hide-nongoodfaith',
+                                       
$page->getContext()->getRequest()->getVal( 'hidenongoodfaith' ),
+                                       [ 'class' => 'mw-input' ]
+                               )
+                       );
+               }
+
                return true;
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I266f6485051f41044f6219a330433737b365a55a
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