Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Properties | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |||
printAvailableActions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @ingroup Maintenance |
19 | */ |
20 | |
21 | use MediaWiki\Extension\MathSearch\Graph\Job\FetchIdsFromWd; |
22 | use MediaWiki\Extension\MathSearch\Graph\Job\NormalizeDoi; |
23 | use MediaWiki\Extension\MathSearch\Graph\Map; |
24 | |
25 | require_once __DIR__ . '/../../../maintenance/Maintenance.php'; |
26 | |
27 | class Properties extends Maintenance { |
28 | |
29 | public function __construct() { |
30 | parent::__construct(); |
31 | $this->addDescription( "Mass perform actions for Properties." ); |
32 | $this->addArg( 'action', 'Action to be performed. ' . $this->printAvailableActions() ); |
33 | $this->setBatchSize( 10000 ); |
34 | |
35 | $this->requireExtension( 'MathSearch' ); |
36 | $this->requireExtension( 'LinkedWiki' ); |
37 | } |
38 | |
39 | public function execute() { |
40 | $type = 'doi'; |
41 | $jobOptions = []; |
42 | $action = $this->getArg( 'action' ); |
43 | if ( $action === 'case-normalize' ) { |
44 | $jobType = NormalizeDoi::class; |
45 | } elseif ( $action === 'fetch-wd' ) { |
46 | $jobType = FetchIdsFromWd::class; |
47 | $type = 'wd'; |
48 | } else { |
49 | $this->error( "Unknown action to be performed.\n" ); |
50 | $this->error( $this->printAvailableActions() ); |
51 | return; |
52 | } |
53 | |
54 | ( new Map( null, $this->getBatchSize() ) )->getJobs( |
55 | Closure::fromCallable( [ $this, 'output' ] ), |
56 | $this->getOption( 'batchSize', $this->getBatchSize() ), |
57 | $type, |
58 | $jobType, |
59 | $jobOptions |
60 | ); |
61 | } |
62 | |
63 | public function printAvailableActions(): string { |
64 | return "Available actions are: case-normalize, fetch-wd.\n"; |
65 | } |
66 | |
67 | } |
68 | |
69 | $maintClass = Properties::class; |
70 | require_once RUN_MAINTENANCE_IF_MAIN; |