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