Sbisson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/327007 )

Change subject: [WIP] Add classes to RC lines so they can be highlighted
......................................................................

[WIP] Add classes to RC lines so they can be highlighted

Bug: T152797
Change-Id: Ib4b95c46a57954ff86eb2ec8b27c3f2dca050289
---
M includes/Hooks.php
1 file changed, 45 insertions(+), 21 deletions(-)


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

diff --git a/includes/Hooks.php b/includes/Hooks.php
index 3f64f3c..1c37e81 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -185,27 +185,24 @@
                }
 
                if ( self::isModelEnabled( 'goodfaith' ) ) {
-                       $goodfaith = $opts->getValue( 'goodfaith' );
-                       if ( $goodfaith !== 'all' ) {
-                               self::joinWithOresTables(
-                                       'goodfaith',
-                                       'rc_this_oldid',
-                                       $tables,
-                                       $fields,
-                                       $join_conds
-                               );
-                               $condition = self::buildRangeFilter(
-                                       'goodfaith',
-                                       $goodfaith,
-                                       $wgOresGoodfaithLevels
-                               );
-                               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';
-                               }
+                       self::joinWithOresTables(
+                               'goodfaith',
+                               'rc_this_oldid',
+                               $tables,
+                               $fields,
+                               $join_conds
+                       );
+                       $condition = self::buildRangeFilter(
+                               'goodfaith',
+                               $opts->getValue( 'goodfaith' ),
+                               $wgOresGoodfaithLevels
+                       );
+                       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';
                        }
                }
 
@@ -293,6 +290,10 @@
                        $parts[1] = ChangesList::flag( 'damaging' ) . $parts[1];
                        $s = implode( $separator, $parts );
                }
+
+               global $wgOresDamagingLevels, $wgOresGoodfaithLevels;
+               self::addClasses( 'goodfaith', $wgOresGoodfaithLevels, $rc, 
$classes );
+               self::addClasses( 'damaging', $wgOresDamagingLevels, $rc, 
$classes );
 
                return true;
        }
@@ -426,6 +427,10 @@
                        $classes[] = 'damaging';
                        $data['recentChangesFlags']['damaging'] = true;
                }
+
+               global $wgOresDamagingLevels, $wgOresGoodfaithLevels;
+               self::addClasses( 'goodfaith', $wgOresGoodfaithLevels, $rcObj, 
$classes );
+               self::addClasses( 'damaging', $wgOresDamagingLevels, $rcObj, 
$classes );
        }
 
        /**
@@ -694,4 +699,23 @@
                }
        }
 
+       private static function addClasses( $model, $levelsDefinition, $rc, 
&$classes ) {
+               if ( self::isModelEnabled( $model ) ) {
+                       $score = $rc->getAttribute( "ores_{$model}_score" );
+                       $levels = array_keys(
+                               array_filter(
+                                       $levelsDefinition,
+                                       function ( $level ) use ( $score ) {
+                                               return $level['min'] <= $score 
&& $score <= $level['max'];
+                                       }
+                               )
+                       );
+                       if ( $levels ) {
+                               foreach ( $levels as $level ) {
+                                       $classes[] = 
"mw-changeslist-$model-$level";
+                               }
+                       }
+               }
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4b95c46a57954ff86eb2ec8b27c3f2dca050289
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

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

Reply via email to