Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
DumpThresholds | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getModels | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace ORES\Maintenance; |
4 | |
5 | use Maintenance; |
6 | use ORES\Services\ORESServices; |
7 | |
8 | require_once getenv( 'MW_INSTALL_PATH' ) !== false |
9 | ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' |
10 | : __DIR__ . '/../../../maintenance/Maintenance.php'; |
11 | |
12 | /** |
13 | * @ingroup Maintenance |
14 | */ |
15 | class DumpThresholds extends Maintenance { |
16 | |
17 | public function __construct() { |
18 | parent::__construct(); |
19 | |
20 | $this->requireExtension( 'ORES' ); |
21 | $this->addDescription( 'Display filtering levels and thresholds for enabled models.' ); |
22 | } |
23 | |
24 | public function execute() { |
25 | $this->output( "Starting..." ); |
26 | $models = $this->getModels(); |
27 | $stats = ORESServices::getThresholdLookup(); |
28 | |
29 | foreach ( $models as $name => $info ) { |
30 | $this->output( "\n$name\n" ); |
31 | $this->output( "\n" . print_r( $stats->getThresholds( $name, false ), true ) . "\n" ); |
32 | } |
33 | |
34 | $this->output( "done.\n" ); |
35 | } |
36 | |
37 | /** |
38 | * Return a list of models available for this wiki. |
39 | * @return array |
40 | * @throws \RuntimeException |
41 | */ |
42 | protected function getModels() { |
43 | global $wgOresModelVersions; |
44 | $modelData = $wgOresModelVersions; |
45 | if ( empty( $modelData['models'] ) ) { |
46 | throw new \RuntimeException( 'Bad response from ORES when requesting models: ' |
47 | . json_encode( $modelData ) ); |
48 | } |
49 | return $modelData['models']; |
50 | } |
51 | |
52 | } |
53 | |
54 | $maintClass = DumpThresholds::class; |
55 | require_once RUN_MAINTENANCE_IF_MAIN; |