Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
11.11% |
2 / 18 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
NewcomerTasksCacheRefreshJob | |
11.11% |
2 / 18 |
|
50.00% |
1 / 2 |
4.81 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
run | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\NewcomerTasks\TaskSuggester; |
4 | |
5 | use GenericParameterJob; |
6 | use GrowthExperiments\GrowthExperimentsServices; |
7 | use GrowthExperiments\NewcomerTasks\Task\TaskSetFilters; |
8 | use Job; |
9 | use MediaWiki\MediaWikiServices; |
10 | use MediaWiki\User\User; |
11 | |
12 | /** |
13 | * Refresh the newcomer tasks cache for a user. |
14 | */ |
15 | class NewcomerTasksCacheRefreshJob extends Job implements GenericParameterJob { |
16 | |
17 | /** @inheritDoc */ |
18 | public function __construct( array $params ) { |
19 | parent::__construct( 'newcomerTasksCacheRefreshJob', $params ); |
20 | $this->removeDuplicates = true; |
21 | } |
22 | |
23 | /** @inheritDoc */ |
24 | public function run() { |
25 | $growthServices = GrowthExperimentsServices::wrap( MediaWikiServices::getInstance() ); |
26 | $newcomerTaskOptions = $growthServices->getNewcomerTasksUserOptionsLookup(); |
27 | $taskSuggester = $growthServices->getTaskSuggesterFactory()->create(); |
28 | $user = User::newFromId( $this->params['userId'] ); |
29 | $taskSuggester->suggest( |
30 | $user, |
31 | new TaskSetFilters( |
32 | $newcomerTaskOptions->getTaskTypeFilter( $user ), |
33 | $newcomerTaskOptions->getTopics( $user ), |
34 | $newcomerTaskOptions->getTopicsMatchMode( $user ) |
35 | ), |
36 | SearchTaskSuggester::DEFAULT_LIMIT, |
37 | null, |
38 | [ 'useCache' => false ] |
39 | ); |
40 | return true; |
41 | } |
42 | } |