Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
CirrusSearchIndexUpdater | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
update | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\NewcomerTasks\AddLink\SearchIndexUpdater; |
4 | |
5 | use CirrusSearch\CirrusSearch; |
6 | use GrowthExperiments\NewcomerTasks\TaskType\LinkRecommendationTaskTypeHandler; |
7 | use MediaWiki\Page\PageIdentityValue; |
8 | use MediaWiki\Revision\RevisionRecord; |
9 | use StatusValue; |
10 | |
11 | /** |
12 | * Update the search index via a direct Cirrus call. This is meant for development setups; |
13 | * in production such updates can be aggregated and batched to reduce the number of index writes. |
14 | */ |
15 | class CirrusSearchIndexUpdater implements SearchIndexUpdater { |
16 | |
17 | /** @inheritDoc */ |
18 | public function update( RevisionRecord $revisionRecord ) { |
19 | $cirrusSearch = new CirrusSearch(); |
20 | // FIXME simplify after T275531 is done |
21 | $pageIdentity = new PageIdentityValue( |
22 | $revisionRecord->getPageId( $revisionRecord->getWikiId() ), |
23 | $revisionRecord->getPage()->getNamespace(), |
24 | $revisionRecord->getPage()->getDBkey(), |
25 | $revisionRecord->getWikiId() |
26 | ); |
27 | $cirrusSearch->updateWeightedTags( $pageIdentity, |
28 | LinkRecommendationTaskTypeHandler::WEIGHTED_TAG_PREFIX ); |
29 | return StatusValue::newGood(); |
30 | } |
31 | |
32 | } |