[MediaWiki-commits] [Gerrit] mediawiki...ORES[master]: Rename Stats to ThresholdLookup and make it a service
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/394760 ) Change subject: Rename Stats to ThresholdLookup and make it a service .. Rename Stats to ThresholdLookup and make it a service The only public method in this class is getThresholds Bug: T181892 Change-Id: I03b9c654deb90b0a1f0bc87d33aa5dfd4f797745 --- M extension.json M includes/Hooks.php M includes/Hooks/ChangesListHooksHandler.php M includes/ServiceWiring.php R includes/ThresholdLookup.php M maintenance/DumpThresholds.php M tests/phpunit/includes/ServiceWiringTest.php R tests/phpunit/includes/ThresholdLookupTest.php 8 files changed, 29 insertions(+), 27 deletions(-) Approvals: jenkins-bot: Verified Thiemo Mättig (WMDE): Looks good to me, approved diff --git a/extension.json b/extension.json index df8881e..0310457 100644 --- a/extension.json +++ b/extension.json @@ -19,7 +19,7 @@ "ORES\\FetchScoreJob": "includes/FetchScoreJob.php", "ORES\\Range": "includes/Range.php", "ORES\\Scoring": "includes/Scoring.php", - "ORES\\Stats": "includes/Stats.php", + "ORES\\ThresholdLookup": "includes/ThresholdLookup.php", "ORES\\Storage\\ModelLookup": "includes/Storage/ModelLookup.php", "ORES\\Storage\\SqlModelLookup": "includes/Storage/SqlModelLookup.php", "ORES\\ApiQueryORES": "includes/ApiQueryORES.php", diff --git a/includes/Hooks.php b/includes/Hooks.php index e0a743c..cdb8c59 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -22,6 +22,7 @@ use JobQueueGroup; use IContextSource; use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; use OutputPage; use RecentChange; use RequestContext; @@ -189,7 +190,7 @@ } public static function getDamagingThresholds() { - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $thresholds = []; foreach ( $stats->getThresholds( 'damaging' ) as $name => $bounds ) { $thresholds[ $name ] = $bounds[ 'min' ]; diff --git a/includes/Hooks/ChangesListHooksHandler.php b/includes/Hooks/ChangesListHooksHandler.php index f3bf99d..93c7d79 100644 --- a/includes/Hooks/ChangesListHooksHandler.php +++ b/includes/Hooks/ChangesListHooksHandler.php @@ -23,9 +23,9 @@ use EnhancedChangesList; use FormOptions; use IContextSource; +use MediaWiki\MediaWikiServices; use ORES\Hooks; use ORES\Range; -use ORES\Stats; use RCCacheEntry; use RecentChange; use SpecialRecentChanges; @@ -43,7 +43,7 @@ return; } - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $changeTypeGroup = $clsp->getFilterGroup( 'changeType' ); $logFilter = $changeTypeGroup->getFilter( 'hidelog' ); @@ -538,7 +538,7 @@ } private static function buildRangeFilter( $name, $filterValue ) { - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $thresholds = $stats->getThresholds( $name ); $selectedLevels = is_array( $filterValue ) ? $filterValue : diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index fc59bf0..458c902 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -16,6 +16,7 @@ namespace ORES; +use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use ORES\Storage\SqlModelLookup; @@ -23,4 +24,13 @@ 'ORESModelLookup' => function ( MediaWikiServices $services ) { return new SqlModelLookup( $services->getDBLoadBalancer() ); }, + + 'ORESThresholdLookup' => function ( MediaWikiServices $services ) { + return new ThresholdLookup( + Api::newFromContext(), + $services->getMainWANObjectCache(), + LoggerFactory::getInstance( 'ORES' ) + ); + } + ]; diff --git a/includes/Stats.php b/includes/ThresholdLookup.php similarity index 95% rename from includes/Stats.php rename to includes/ThresholdLookup.php index 2b9922b..87a0603 100644 --- a/includes/Stats.php +++ b/includes/ThresholdLookup.php @@ -16,12 +16,11 @@ namespace ORES; -use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use Psr\Log\LoggerInterface; use WANObjectCache; -class Stats { +class ThresholdLookup { /** * @var Api @@ -29,7 +28,7 @@ private $api; /** -* @var \WANObjectCache +* @var WANObjectCache */ private $cache; @@ -40,7 +39,7 @@ /** * @param Api
[MediaWiki-commits] [Gerrit] mediawiki...ORES[master]: Rename Stats to ThresholdLookup and make it a service
Ladsgroup has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/394760 ) Change subject: Rename Stats to ThresholdLookup and make it a service .. Rename Stats to ThresholdLookup and make it a service The only public method in this class is getThresholds Bug: T181892 Change-Id: I03b9c654deb90b0a1f0bc87d33aa5dfd4f797745 --- M extension.json M includes/Hooks.php M includes/Hooks/ChangesListHooksHandler.php M includes/ServiceWiring.php R includes/ThresholdLookup.php M maintenance/DumpThresholds.php M tests/phpunit/includes/ServiceWiringTest.php R tests/phpunit/includes/ThresholdLookupTest.php 8 files changed, 29 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES refs/changes/60/394760/1 diff --git a/extension.json b/extension.json index df8881e..0310457 100644 --- a/extension.json +++ b/extension.json @@ -19,7 +19,7 @@ "ORES\\FetchScoreJob": "includes/FetchScoreJob.php", "ORES\\Range": "includes/Range.php", "ORES\\Scoring": "includes/Scoring.php", - "ORES\\Stats": "includes/Stats.php", + "ORES\\ThresholdLookup": "includes/ThresholdLookup.php", "ORES\\Storage\\ModelLookup": "includes/Storage/ModelLookup.php", "ORES\\Storage\\SqlModelLookup": "includes/Storage/SqlModelLookup.php", "ORES\\ApiQueryORES": "includes/ApiQueryORES.php", diff --git a/includes/Hooks.php b/includes/Hooks.php index e0a743c..cdb8c59 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -22,6 +22,7 @@ use JobQueueGroup; use IContextSource; use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; use OutputPage; use RecentChange; use RequestContext; @@ -189,7 +190,7 @@ } public static function getDamagingThresholds() { - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $thresholds = []; foreach ( $stats->getThresholds( 'damaging' ) as $name => $bounds ) { $thresholds[ $name ] = $bounds[ 'min' ]; diff --git a/includes/Hooks/ChangesListHooksHandler.php b/includes/Hooks/ChangesListHooksHandler.php index f3bf99d..93c7d79 100644 --- a/includes/Hooks/ChangesListHooksHandler.php +++ b/includes/Hooks/ChangesListHooksHandler.php @@ -23,9 +23,9 @@ use EnhancedChangesList; use FormOptions; use IContextSource; +use MediaWiki\MediaWikiServices; use ORES\Hooks; use ORES\Range; -use ORES\Stats; use RCCacheEntry; use RecentChange; use SpecialRecentChanges; @@ -43,7 +43,7 @@ return; } - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $changeTypeGroup = $clsp->getFilterGroup( 'changeType' ); $logFilter = $changeTypeGroup->getFilter( 'hidelog' ); @@ -538,7 +538,7 @@ } private static function buildRangeFilter( $name, $filterValue ) { - $stats = Stats::newFromGlobalState(); + $stats = MediaWikiServices::getInstance()->getService( 'ORESThresholdLookup' ); $thresholds = $stats->getThresholds( $name ); $selectedLevels = is_array( $filterValue ) ? $filterValue : diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index fc59bf0..458c902 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -16,6 +16,7 @@ namespace ORES; +use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use ORES\Storage\SqlModelLookup; @@ -23,4 +24,13 @@ 'ORESModelLookup' => function ( MediaWikiServices $services ) { return new SqlModelLookup( $services->getDBLoadBalancer() ); }, + + 'ORESThresholdLookup' => function ( MediaWikiServices $services ) { + return new ThresholdLookup( + Api::newFromContext(), + $services->getMainWANObjectCache(), + LoggerFactory::getInstance( 'ORES' ) + ); + } + ]; diff --git a/includes/Stats.php b/includes/ThresholdLookup.php similarity index 95% rename from includes/Stats.php rename to includes/ThresholdLookup.php index 2b9922b..87a0603 100644 --- a/includes/Stats.php +++ b/includes/ThresholdLookup.php @@ -16,12 +16,11 @@ namespace ORES; -use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use Psr\Log\LoggerInterface; use WANObjectCache; -class Stats { +class ThresholdLookup { /** * @var Api @@ -29,7 +28,7 @@ private $api; /** -* @var \WANObjectCache +* @var WANObjectCache */ private $cache; @@ -40,7 +39,7 @@ /** * @param Api