Ladsgroup has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/402488 )
Change subject: Split Hooks::onChangesListSpecialPageStructuredFilters
......................................................................
Split Hooks::onChangesListSpecialPageStructuredFilters
This monster of a method needs to be split to way more methods
This is the first step and it's just moving code around.
Change-Id: I9d85f6e5561d409b89fd2d579aa2244c45776987
---
M includes/Hooks/ChangesListHooksHandler.php
1 file changed, 119 insertions(+), 106 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES
refs/changes/88/402488/1
diff --git a/includes/Hooks/ChangesListHooksHandler.php
b/includes/Hooks/ChangesListHooksHandler.php
index b6a722e..c8ff331 100644
--- a/includes/Hooks/ChangesListHooksHandler.php
+++ b/includes/Hooks/ChangesListHooksHandler.php
@@ -60,59 +60,9 @@
$highlightDefault = false;
}
- $damagingLevels = $stats->getThresholds( 'damaging' );
- $filters = [];
- if ( isset( $damagingLevels[ 'likelygood' ] ) ) {
- $filters[ 'likelygood' ] = [
- 'name' => 'likelygood',
- 'label' =>
'ores-rcfilters-damaging-likelygood-label',
- 'description' =>
'ores-rcfilters-damaging-likelygood-desc',
- 'cssClassSuffix' =>
'damaging-likelygood',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'damaging',
- $damagingLevels['likelygood']
- ),
- ];
- }
- if ( isset( $damagingLevels[ 'maybebad' ] ) ) {
- $filters[ 'maybebad' ] = [
- 'name' => 'maybebad',
- 'label' =>
'ores-rcfilters-damaging-maybebad-label',
- 'description' =>
'ores-rcfilters-damaging-maybebad-desc',
- 'cssClassSuffix' => 'damaging-maybebad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'damaging',
- $damagingLevels['maybebad']
- ),
- ];
- }
- if ( isset( $damagingLevels[ 'likelybad' ] ) ) {
- $descMsg = isset( $filters[ 'maybebad' ] ) ?
-
'ores-rcfilters-damaging-likelybad-desc-low' :
-
'ores-rcfilters-damaging-likelybad-desc-high';
- $filters[ 'likelybad' ] = [
- 'name' => 'likelybad',
- 'label' =>
'ores-rcfilters-damaging-likelybad-label',
- 'description' => $descMsg,
- 'cssClassSuffix' =>
'damaging-likelybad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'damaging',
- $damagingLevels['likelybad']
- ),
- ];
- }
- if ( isset( $damagingLevels[ 'verylikelybad' ] ) ) {
- $filters[ 'verylikelybad' ] = [
- 'name' => 'verylikelybad',
- 'label' =>
'ores-rcfilters-damaging-verylikelybad-label',
- 'description' =>
'ores-rcfilters-damaging-verylikelybad-desc',
- 'cssClassSuffix' =>
'damaging-verylikelybad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'damaging',
- $damagingLevels['verylikelybad']
- ),
- ];
- }
+ $filters =
self::getDamagingStructuredFiltersOnChangesList(
+ $stats->getThresholds( 'damaging' )
+ );
if ( $filters ) {
$newDamagingGroup = new
ChangesListStringOptionsFilterGroup( [
@@ -238,59 +188,9 @@
$clsp->registerFilterGroup( $legacyDamagingGroup );
}
if ( Hooks::isModelEnabled( 'goodfaith' ) ) {
- $goodfaithLevels = $stats->getThresholds( 'goodfaith' );
- $filters = [];
- if ( isset( $goodfaithLevels['likelygood'] ) ) {
- $filters[ 'likelygood' ] = [
- 'name' => 'likelygood',
- 'label' =>
'ores-rcfilters-goodfaith-good-label',
- 'description' =>
'ores-rcfilters-goodfaith-good-desc',
- 'cssClassSuffix' => 'goodfaith-good',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'goodfaith',
- $goodfaithLevels['likelygood']
- ),
- ];
- }
- if ( isset( $goodfaithLevels['maybebad'] ) ) {
- $filters[ 'maybebad' ] = [
- 'name' => 'maybebad',
- 'label' =>
'ores-rcfilters-goodfaith-maybebad-label',
- 'description' =>
'ores-rcfilters-goodfaith-maybebad-desc',
- 'cssClassSuffix' =>
'goodfaith-maybebad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'goodfaith',
- $goodfaithLevels['maybebad']
- ),
- ];
- }
- if ( isset( $goodfaithLevels['likelybad'] ) ) {
- $descMsg = isset( $filters[ 'maybebad' ] ) ?
- 'ores-rcfilters-goodfaith-bad-desc-low'
:
-
'ores-rcfilters-goodfaith-bad-desc-high';
- $filters[ 'likelybad' ] = [
- 'name' => 'likelybad',
- 'label' =>
'ores-rcfilters-goodfaith-bad-label',
- 'description' => $descMsg,
- 'cssClassSuffix' => 'goodfaith-bad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'goodfaith',
- $goodfaithLevels['likelybad']
- ),
- ];
- }
- if ( isset( $goodfaithLevels['verylikelybad'] ) ) {
- $filters[ 'verylikelybad' ] = [
- 'name' => 'verylikelybad',
- 'label' =>
'ores-rcfilters-goodfaith-verylikelybad-label',
- 'description' =>
'ores-rcfilters-goodfaith-verylikelybad-desc',
- 'cssClassSuffix' =>
'goodfaith-verylikelybad',
- 'isRowApplicableCallable' =>
self::makeApplicableCallback(
- 'goodfaith',
-
$goodfaithLevels['verylikelybad']
- ),
- ];
- }
+ $filters =
self::getGoodFaithStructuredFiltersOnChangesList(
+ $stats->getThresholds( 'goodfaith' )
+ );
if ( $filters ) {
$goodfaithGroup = new
ChangesListStringOptionsFilterGroup( [
@@ -354,6 +254,119 @@
}
}
+ private static function getDamagingStructuredFiltersOnChangesList(
array $damagingLevels ) {
+ $filters = [];
+ if ( isset( $damagingLevels[ 'likelygood' ] ) ) {
+ $filters[ 'likelygood' ] = [
+ 'name' => 'likelygood',
+ 'label' =>
'ores-rcfilters-damaging-likelygood-label',
+ 'description' =>
'ores-rcfilters-damaging-likelygood-desc',
+ 'cssClassSuffix' => 'damaging-likelygood',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'damaging',
+ $damagingLevels['likelygood']
+ ),
+ ];
+ }
+ if ( isset( $damagingLevels[ 'maybebad' ] ) ) {
+ $filters[ 'maybebad' ] = [
+ 'name' => 'maybebad',
+ 'label' =>
'ores-rcfilters-damaging-maybebad-label',
+ 'description' =>
'ores-rcfilters-damaging-maybebad-desc',
+ 'cssClassSuffix' => 'damaging-maybebad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'damaging',
+ $damagingLevels['maybebad']
+ ),
+ ];
+ }
+ if ( isset( $damagingLevels[ 'likelybad' ] ) ) {
+ $descMsg = isset( $filters[ 'maybebad' ] ) ?
+ 'ores-rcfilters-damaging-likelybad-desc-low' :
+ 'ores-rcfilters-damaging-likelybad-desc-high';
+ $filters[ 'likelybad' ] = [
+ 'name' => 'likelybad',
+ 'label' =>
'ores-rcfilters-damaging-likelybad-label',
+ 'description' => $descMsg,
+ 'cssClassSuffix' => 'damaging-likelybad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'damaging',
+ $damagingLevels['likelybad']
+ ),
+ ];
+ }
+ if ( isset( $damagingLevels[ 'verylikelybad' ] ) ) {
+ $filters[ 'verylikelybad' ] = [
+ 'name' => 'verylikelybad',
+ 'label' =>
'ores-rcfilters-damaging-verylikelybad-label',
+ 'description' =>
'ores-rcfilters-damaging-verylikelybad-desc',
+ 'cssClassSuffix' => 'damaging-verylikelybad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'damaging',
+ $damagingLevels['verylikelybad']
+ ),
+ ];
+ }
+ return $filters;
+ }
+
+ private static function getGoodFaithStructuredFiltersOnChangesList(
array $goodfaithLevels ) {
+ $filters = [];
+ if ( isset( $goodfaithLevels['likelygood'] ) ) {
+ $filters[ 'likelygood' ] = [
+ 'name' => 'likelygood',
+ 'label' =>
'ores-rcfilters-goodfaith-good-label',
+ 'description' =>
'ores-rcfilters-goodfaith-good-desc',
+ 'cssClassSuffix' => 'goodfaith-good',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'goodfaith',
+ $goodfaithLevels['likelygood']
+ ),
+ ];
+ }
+ if ( isset( $goodfaithLevels['maybebad'] ) ) {
+ $filters[ 'maybebad' ] = [
+ 'name' => 'maybebad',
+ 'label' =>
'ores-rcfilters-goodfaith-maybebad-label',
+ 'description' =>
'ores-rcfilters-goodfaith-maybebad-desc',
+ 'cssClassSuffix' => 'goodfaith-maybebad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'goodfaith',
+ $goodfaithLevels['maybebad']
+ ),
+ ];
+ }
+ if ( isset( $goodfaithLevels['likelybad'] ) ) {
+ $descMsg = isset( $filters[ 'maybebad' ] ) ?
+ 'ores-rcfilters-goodfaith-bad-desc-low' :
+ 'ores-rcfilters-goodfaith-bad-desc-high';
+ $filters[ 'likelybad' ] = [
+ 'name' => 'likelybad',
+ 'label' => 'ores-rcfilters-goodfaith-bad-label',
+ 'description' => $descMsg,
+ 'cssClassSuffix' => 'goodfaith-bad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'goodfaith',
+ $goodfaithLevels['likelybad']
+ ),
+ ];
+ }
+ if ( isset( $goodfaithLevels['verylikelybad'] ) ) {
+ $filters[ 'verylikelybad' ] = [
+ 'name' => 'verylikelybad',
+ 'label' =>
'ores-rcfilters-goodfaith-verylikelybad-label',
+ 'description' =>
'ores-rcfilters-goodfaith-verylikelybad-desc',
+ 'cssClassSuffix' => 'goodfaith-verylikelybad',
+ 'isRowApplicableCallable' =>
self::makeApplicableCallback(
+ 'goodfaith',
+ $goodfaithLevels['verylikelybad']
+ ),
+ ];
+ }
+
+ return $filters;
+ }
+
public static function onChangesListSpecialPageQuery(
$name, array &$tables, array &$fields, array &$conds,
array &$query_options, array &$join_conds, FormOptions $opts
--
To view, visit https://gerrit.wikimedia.org/r/402488
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d85f6e5561d409b89fd2d579aa2244c45776987
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits