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 LoggerInterface */ |
25 | private $logger; |
26 | |
27 | /** @var UtteranceStore */ |
28 | private $utteranceStore; |
29 | |
30 | /** @var string */ |
31 | private $language; |
32 | |
33 | /** @var string */ |
34 | private $voice; |
35 | |
36 | /** |
37 | * @since 0.1.7 |
38 | * @param Title $title |
39 | * @param array $params [ 'language' => string, 'voice' => string|null ] |
40 | */ |
41 | public function __construct( $title, $params ) { |
42 | parent::__construct( 'flushUtterancesFromStoreByLanguageAndVoice', $title, $params ); |
43 | $this->logger = LoggerFactory::getInstance( 'Wikispeech' ); |
44 | $this->utteranceStore = new UtteranceStore(); |
45 | $this->language = $params['language']; |
46 | $this->voice = $params['voice']; |
47 | } |
48 | |
49 | /** |
50 | * Executed by the job queue. |
51 | * |
52 | * @since 0.1.7 |
53 | * @return bool success |
54 | */ |
55 | public function run() { |
56 | $flushedUtterances = $this->utteranceStore->flushUtterancesByLanguageAndVoice( |
57 | $this->language, |
58 | $this->voice |
59 | ); |
60 | $this->logger->info( |
61 | "Flushed {flushedUtterances} expired utterances from store.", |
62 | [ 'flushedUtterances' => $flushedUtterances ] |
63 | ); |
64 | return true; |
65 | } |
66 | |
67 | } |