Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
GetPraiseworthyMentees | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
initServices | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Maintenance; |
4 | |
5 | use GrowthExperiments\GrowthExperimentsServices; |
6 | use GrowthExperiments\MentorDashboard\PersonalizedPraise\PraiseworthyMenteeSuggester; |
7 | use Maintenance; |
8 | use MediaWiki\MediaWikiServices; |
9 | use MediaWiki\User\UserIdentityLookup; |
10 | |
11 | $IP = getenv( 'MW_INSTALL_PATH' ); |
12 | if ( $IP === false ) { |
13 | $IP = __DIR__ . '/../../..'; |
14 | } |
15 | require_once "$IP/maintenance/Maintenance.php"; |
16 | |
17 | class GetPraiseworthyMentees extends Maintenance { |
18 | |
19 | private UserIdentityLookup $userIdentityLookup; |
20 | private PraiseworthyMenteeSuggester $suggester; |
21 | |
22 | public function __construct() { |
23 | parent::__construct(); |
24 | $this->requireExtension( 'GrowthExperiments' ); |
25 | $this->addDescription( 'Get list of all praiseworthy mentees for a given mentor' ); |
26 | |
27 | $this->addOption( |
28 | 'uncached', |
29 | 'Ignore cached values; calculate list of praiseworthy mentees (can take several minutes)' |
30 | ); |
31 | $this->addArg( |
32 | 'mentor', |
33 | 'Username of the mentor to get praiseworthy mentees for' |
34 | ); |
35 | } |
36 | |
37 | private function initServices() { |
38 | $services = MediaWikiServices::getInstance(); |
39 | $geServices = GrowthExperimentsServices::wrap( $services ); |
40 | |
41 | $this->userIdentityLookup = $services->getUserIdentityLookup(); |
42 | $this->suggester = $geServices->getPraiseworthyMenteeSuggester(); |
43 | } |
44 | |
45 | /** |
46 | * @inheritDoc |
47 | */ |
48 | public function execute() { |
49 | $this->initServices(); |
50 | |
51 | $mentor = $this->userIdentityLookup->getUserIdentityByName( $this->getArg( 0 ) ); |
52 | if ( !$mentor ) { |
53 | $this->fatalError( 'Mentor not found. Maybe a typo in the username?' ); |
54 | } |
55 | |
56 | if ( $this->hasOption( 'uncached' ) ) { |
57 | $praiseworthyMentees = $this->suggester->getPraiseworthyMenteesForMentorUncached( $mentor ); |
58 | } else { |
59 | $praiseworthyMentees = $this->suggester->getPraiseworthyMenteesForMentor( $mentor ); |
60 | } |
61 | |
62 | $this->output( "List of praiseworthy mentees for User:" . $mentor->getName() . PHP_EOL ); |
63 | foreach ( $praiseworthyMentees as $mentee ) { |
64 | $this->output( "* User:" . $mentee->getUser()->getName() . PHP_EOL ); |
65 | } |
66 | } |
67 | } |
68 | $maintClass = GetPraiseworthyMentees::class; |
69 | require_once RUN_MAINTENANCE_IF_MAIN; |