Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| FlushUtterancesFromStoreByLanguageAndVoiceJob | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Wikispeech\Utterance; |
| 4 | |
| 5 | /** |
| 6 | * @file |
| 7 | * @ingroup Extensions |
| 8 | * @license GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | use Job; |
| 12 | use MediaWiki\Logger\LoggerFactory; |
| 13 | use Mediawiki\Title\Title; |
| 14 | use Psr\Log\LoggerInterface; |
| 15 | |
| 16 | /** |
| 17 | * @see UtteranceStore::flushUtterancesByLanguageAndVoice() |
| 18 | * @see FlushUtterancesFromStoreByLanguageAndVoiceJobQueue |
| 19 | * |
| 20 | * @since 0.1.7 |
| 21 | */ |
| 22 | class FlushUtterancesFromStoreByLanguageAndVoiceJob extends Job { |
| 23 | |
| 24 | /** @var UtteranceStore */ |
| 25 | private $utteranceStore; |
| 26 | |
| 27 | /** @var LoggerInterface */ |
| 28 | private $logger; |
| 29 | |
| 30 | /** @var string */ |
| 31 | private $language; |
| 32 | |
| 33 | /** @var string */ |
| 34 | private $voice; |
| 35 | |
| 36 | /** |
| 37 | * @since 0.1.13 add service $utteranceStore to constructor |
| 38 | * @since 0.1.7 |
| 39 | * @param Title $title |
| 40 | * @param array $params [ 'language' => string, 'voice' => string|null ] |
| 41 | * @param UtteranceStore $utteranceStore |
| 42 | */ |
| 43 | public function __construct( $title, $params, $utteranceStore ) { |
| 44 | parent::__construct( 'flushUtterancesFromStoreByLanguageAndVoice', $title, $params ); |
| 45 | $this->logger = LoggerFactory::getInstance( 'Wikispeech' ); |
| 46 | $this->language = $params['language']; |
| 47 | $this->voice = $params['voice']; |
| 48 | $this->utteranceStore = $utteranceStore; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Executed by the job queue. |
| 53 | * |
| 54 | * @since 0.1.7 |
| 55 | * @return bool success |
| 56 | */ |
| 57 | public function run() { |
| 58 | $flushedUtterances = $this->utteranceStore->flushUtterancesByLanguageAndVoice( |
| 59 | $this->language, |
| 60 | $this->voice |
| 61 | ); |
| 62 | $this->logger->info( |
| 63 | "Flushed {flushedUtterances} expired utterances from store.", |
| 64 | [ 'flushedUtterances' => $flushedUtterances ] |
| 65 | ); |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | } |