Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
MenteeOverviewUpdateDataForMentorJob
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace GrowthExperiments\MentorDashboard\MenteeOverview;
4
5use GenericParameterJob;
6use GrowthExperiments\GrowthExperimentsServices;
7use Job;
8use MediaWiki\MediaWikiServices;
9use MediaWiki\User\UserIdentityLookup;
10
11/**
12 * Job to update data shown by the mentor dashboard for a given mentor
13 *
14 * This job is started by the mentor, if they wish to do an one-off update
15 * of the data.
16 *
17 * The following job parameters are required:
18 *     - mentorId: user ID of the mentor
19 */
20class MenteeOverviewUpdateDataForMentorJob extends Job implements GenericParameterJob {
21
22    /** @var MenteeOverviewDataUpdater */
23    private $menteeOverviewDataUpdater;
24
25    /** @var UserIdentityLookup */
26    private $userIdentityLookup;
27
28    /**
29     * @inheritDoc
30     */
31    public function __construct( $params = null ) {
32        parent::__construct( 'menteeOverviewUpdateDataForMentor', $params );
33        $this->removeDuplicates = true;
34
35        // Init services
36        $services = MediaWikiServices::getInstance();
37        $this->menteeOverviewDataUpdater = GrowthExperimentsServices::wrap( $services )
38            ->getMenteeOverviewDataUpdater();
39        $this->userIdentityLookup = $services->getUserIdentityLookup();
40    }
41
42    public function run() {
43        $mentor = $this->userIdentityLookup->getUserIdentityByUserId( $this->params['mentorId'] );
44        if ( !$mentor ) {
45            // invalid ID passed
46            return true;
47        }
48
49        $this->menteeOverviewDataUpdater->updateDataForMentor(
50            $mentor
51        );
52        return true;
53    }
54}