summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/src/Statistics/UpdateTranslatorActivityJob.php')
-rw-r--r--MLEB/Translate/src/Statistics/UpdateTranslatorActivityJob.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/MLEB/Translate/src/Statistics/UpdateTranslatorActivityJob.php b/MLEB/Translate/src/Statistics/UpdateTranslatorActivityJob.php
new file mode 100644
index 00000000..c07c25fe
--- /dev/null
+++ b/MLEB/Translate/src/Statistics/UpdateTranslatorActivityJob.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+namespace MediaWiki\Extensions\Translate\Statistics;
+
+use GenericParameterJob;
+use MediaWiki\Extensions\Translate\Jobs\GenericTranslateJob;
+use MediaWiki\Extensions\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;
+ }
+}