Catrope has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/341732 )
Change subject: [WIP] Add ORES filters to new RCFilters ...................................................................... [WIP] Add ORES filters to new RCFilters And port old-style filter to the new hooks. The code works, but needs to be cleaned up. The old hooks need to be removed, and the code that remains after that may need some cleanup or refactoring after that. Change-Id: I82516b0bb5be3b4f3c1a9782b87978a6f01b0c4f Depends-On: Iec2d82f6a830403d1c948a280efa58992e0cdee7 Bug: T158459 --- M extension.json M i18n/en.json M includes/Hooks.php 3 files changed, 160 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES refs/changes/32/341732/1 diff --git a/extension.json b/extension.json index d0336f0..c55d03d 100644 --- a/extension.json +++ b/extension.json @@ -30,6 +30,9 @@ "ChangesListSpecialPageFilters": [ "ORES\\Hooks::onChangesListSpecialPageFilters" ], + "ChangesListSpecialPageStructuredFilters": [ + "ORES\\Hooks::onChangesListSpecialPageStructuredFilters" + ], "ChangesListSpecialPageQuery": [ "ORES\\Hooks::onChangesListSpecialPageQuery" ], diff --git a/i18n/en.json b/i18n/en.json index d9e9dbf..7fb37e3 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -17,6 +17,22 @@ "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", + "ores-rcfilters-damaging-title": "Contribution quality predictions", + "ores-rcfilters-damaging-likelygood-label": "Very likely good", + "ores-rcfilters-damaging-likelygood-desc": "Highly accurate at finding almost all problem-free edits.", + "ores-rcfilters-damaging-maybebad-label": "May have problems", + "ores-rcfilters-damaging-maybebad-desc": "Finds most flawed or damaging edits but with lower accuracy.", + "ores-rcfilters-damaging-likelybad-label": "Likely have problems", + "ores-rcfilters-damaging-likelybad-desc": "Finds half of flawed or damaging edits with medium accuracy.", + "ores-rcfilters-damaging-verylikelybad-label": "Very likely have problems", + "ores-rcfilters-damaging-verylikelybad-desc": "Highly accurate at finding the most obvious 10% of flawed or damaging edits.", + "ores-rcfilters-goodfaith-title": "User intent predictions", + "ores-rcfilters-goodfaith-good-label": "Very likely good faith", + "ores-rcfilters-goodfaith-good-desc": "Highly accurate at finding almost all good-faith edits.", + "ores-rcfilters-goodfaith-maybebad-label": "May be bad faith", + "ores-rcfilters-goodfaith-maybebad-desc": "Finds most bad-faith edits but with a lower accuracy.", + "ores-rcfilters-goodfaith-bad-label": "Likely bad faith", + "ores-rcfilters-goodfaith-bad-desc": "With medium accuracy, finds the most obvious obvious 25% of bad-faith edits.", "prefs-ores" : "Revision scoring", "apihelp-query+ores-description": "Return ORES configuration and model data for this wiki.", "apihelp-query+ores-example-simple": "Fetch ORES data:", diff --git a/includes/Hooks.php b/includes/Hooks.php index bc3ce2f..111f0d9 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -4,6 +4,7 @@ use BetaFeatures; use ChangesList; +use ChangesListFilterGroup; use ChangesListSpecialPage; use ContribsPager; use DatabaseUpdater; @@ -77,6 +78,143 @@ } } + public static function onChangesListSpecialPageStructuredFilters( + ChangesListSpecialPage $clsp + ) { + if ( !self::oresEnabled( $clsp->getUser() ) ) { + return; + } + if ( self::isModelEnabled( 'damaging' ) ) { + $newDamagingGroup = new ChangesListFilterGroup( [ + 'name' => 'damaging', + 'title' => 'ores-rcfilters-damaging-title', + 'type' => ChangesListFilterGroup::STRING_OPTIONS, + 'priority' => 1, + 'filters' => [ + [ + 'name' => 'likelygood', + 'label' => 'ores-rcfilters-damaging-likelygood-label', + 'description' => 'ores-rcfilters-damaging-likelygood-desc', + ], + [ + 'name' => 'maybebad', + 'label' => 'ores-rcfilters-damaging-maybebad-label', + 'description' => 'ores-rcfilters-damaging-maybebad-desc', + ], + [ + 'name' => 'likelybad', + 'label' => 'ores-rcfilters-damaging-likelybad-label', + 'description' => 'ores-rcfilters-damaging-likelybad-desc', + ], + [ + 'name' => 'verylikelybad', + 'label' => 'ores-rcfilters-damaging-verylikelybad-label', + 'description' => 'ores-rcfilters-damaging-verylikelybad-desc', + ], + ], + 'default' => ChangesListFilterGroup::NONE, + 'isFullCoverage' => true, + 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + self::joinWithOresTables( + 'damaging', + 'rc_this_oldid', + $tables, + $fields, + $join_conds + ); + $condition = self::buildRangeFilter( 'damaging', $selectedValues ); + if ( $condition ) { + // TODO when can this ever return false? + $conds[] = $condition; + $join_conds['ores_damaging_mdl'][0] = 'INNER JOIN'; + $join_conds['ores_damaging_cls'][0] = 'INNER JOIN'; + // Performance hack: add STRAIGHT_JOIN (146111) + $query_options[] = 'STRAIGHT_JOIN'; + } + }, + ] ); + // TODO add subset rules once they are supported + $clsp->registerFilterGroup( $newDamagingGroup ); + + $legacyDamagingGroup = new ChangesListFilterGroup( [ + 'name' => 'ores', + 'priority' => -1, // FIXME should not be needed + 'type' => ChangesListFilterGroup::SEND_UNSELECTED_IF_ANY, + 'filters' => [ + [ + 'name' => 'damaging', + 'showHide' => 'ores-damaging-filter', // TODO different for watchlist? + 'default' => false, + 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds ) { + self::joinWithOresTables( + 'damaging', + 'rc_this_oldid', + $tables, + $fields, + $join_conds + ); + self::hideNonDamagingFilter( $fields, $conds, true, $ctx->getUser() ); + $conds['rc_patrolled'] = 0; + $join_conds['ores_damaging_mdl'][0] = 'INNER JOIN'; + $join_conds['ores_damaging_cls'][0] = 'INNER JOIN'; + // Performance hack: add STRAIGHT_JOIN (146111) + $query_options[] = 'STRAIGHT_JOIN'; + }, + ] + ], + + ] ); + // TODO add replaced in new UI flag + $clsp->registerFilterGroup( $legacyDamagingGroup ); + // TODO get rid of all old hooks + } + if ( self::isModelEnabled( 'goodfaith' ) ) { + $goodfaithGroup = new ChangesListFilterGroup( [ + 'name' => 'goodfaith', + 'title' => 'ores-rcfilters-goodfaith-title', + 'type' => ChangesListFilterGroup::STRING_OPTIONS, + 'priority' => 1, + 'filters' => [ + [ + 'name' => 'good', + 'label' => 'ores-rcfilters-goodfaith-good-label', + 'description' => 'ores-rcfilters-goodfaith-good-desc', + ], + [ + 'name' => 'maybebad', + 'label' => 'ores-rcfilters-goodfaith-maybebad-label', + 'description' => 'ores-rcfilters-goodfaith-maybebad-desc', + ], + [ + 'name' => 'bad', + 'label' => 'ores-rcfilters-goodfaith-bad-label', + 'description' => 'ores-rcfilters-goodfaith-bad-desc', + ], + ], + 'default' => ChangesListFilterGroup::NONE, + 'isFullCoverage' => true, + 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + self::joinWithOresTables( + 'goodfaith', + 'rc_this_oldid', + $tables, + $fields, + $join_conds + ); + $condition = self::buildRangeFilter( 'goodfaith', $selectedValues ); + if ( $condition ) { + $conds[] = $condition; + $join_conds['ores_goodfaith_mdl'][0] = 'INNER JOIN'; + $join_conds['ores_goodfaith_cls'][0] = 'INNER JOIN'; + // Performance hack: add STRAIGHT_JOIN (146111) + $query_options[] = 'STRAIGHT_JOIN'; + } + }, + ] ); + $clsp->registerFilterGroup( $goodfaithGroup ); + } + } + /** * Add an ORES filter to the recent changes results * @@ -87,6 +225,7 @@ ChangesListSpecialPage $clsp, &$filters ) { + return; if ( !self::oresEnabled( $clsp->getUser() ) ) { return; } @@ -131,6 +270,7 @@ $name, array &$tables, array &$fields, array &$conds, array &$query_options, array &$join_conds, FormOptions $opts ) { + return; global $wgUser; if ( !self::oresEnabled( $wgUser ) ) { @@ -624,7 +764,7 @@ $stats = Stats::newFromGlobalState(); $thresholds = $stats->getThresholds( $name ); - $selectedLevels = explode( ',', strtolower( $filterValue ) ); + $selectedLevels = is_array( $filterValue ) ? $filterValue : explode( ',', strtolower( $filterValue ) ); $selectedLevels = array_intersect( $selectedLevels, array_keys( $thresholds ) -- To view, visit https://gerrit.wikimedia.org/r/341732 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82516b0bb5be3b4f3c1a9782b87978a6f01b0c4f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ORES Gerrit-Branch: master Gerrit-Owner: Catrope <r...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits