Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
UpdateTranslatorActivityJob | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
newJobForLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * @file |
4 | * @author Niklas Laxström |
5 | * @license GPL-2.0-or-later |
6 | */ |
7 | |
8 | namespace MediaWiki\Extension\Translate\Statistics; |
9 | |
10 | use GenericParameterJob; |
11 | use MediaWiki\Extension\Translate\Jobs\GenericTranslateJob; |
12 | use MediaWiki\Extension\Translate\Services; |
13 | |
14 | /** @since 2020.04 */ |
15 | class UpdateTranslatorActivityJob extends GenericTranslateJob implements GenericParameterJob { |
16 | public function __construct( array $params ) { |
17 | parent::__construct( 'UpdateTranslatorActivity', $params ); |
18 | $this->removeDuplicates = true; |
19 | } |
20 | |
21 | public static function newJobForLanguage( string $language ): self { |
22 | return new self( [ 'language' => $language ] ); |
23 | } |
24 | |
25 | public function run() { |
26 | $activity = Services::getInstance()->getTranslatorActivity(); |
27 | |
28 | try { |
29 | $activity->updateLanguage( $this->getParams()['language'] ); |
30 | } catch ( StatisticsUnavailable $e ) { |
31 | $this->logInfo( $e->getMessage() ); |
32 | // The job will be retried according to JobQueue configuration |
33 | return false; |
34 | } |
35 | |
36 | return true; |
37 | } |
38 | } |