jenkins-bot has submitted this change and it was merged.

Change subject: Bucket users for the Task Recs experiment v1
......................................................................


Bucket users for the Task Recs experiment v1

* If the user is logged in and recently signed up, then they are entered
  into the experiment
* Assign the user to one of the following buckets based on their ID:
    * control
    * post-edit
    * flyout
    * both

Change-Id: I1604b364dade6027c28b92d6711a5182bba3e2ef
---
M GettingStarted.php
M Hooks.php
2 files changed, 39 insertions(+), 4 deletions(-)

Approvals:
  Robmoen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GettingStarted.php b/GettingStarted.php
index 490f244..3f62bdd 100644
--- a/GettingStarted.php
+++ b/GettingStarted.php
@@ -76,6 +76,17 @@
  */
 $wgGettingStartedRunTest = false;
 
+/**
+ * @var array The buckets available in v1 of the Task Recommendations
+ *     experiment.
+ */
+$wgGettingStartedTaskRecsExperimentBuckets = array(
+       'control',
+       'post-edit',
+       'flyout',
+       'post-edit-flyout'
+);
+
 $wgAutoloadClasses += array(
        'GettingStarted\Hooks' => __DIR__ . '/Hooks.php',
        'GettingStarted\RedisCategorySync' => __DIR__ . 
'/RedisCategorySync.php',
diff --git a/Hooks.php b/Hooks.php
index 1146798..2edd4c7 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -240,6 +240,18 @@
                return true;
        }
 
+       protected static function getTaskRecommendationExperimentV1Bucket( User 
$user ) {
+               global $wgGettingStartedTaskRecsExperimentBuckets;
+
+               if ( !$user->isLoggedIn() || !self::isRecentSignup( $user ) ) {
+                       return 'control';
+               }
+
+               $numBuckets = count( $wgGettingStartedTaskRecsExperimentBuckets 
);
+
+               return $wgGettingStartedTaskRecsExperimentBuckets[ 
$user->getId() % $numBuckets ];
+       }
+
        /**
         * Adds applicable modules to the page
         *
@@ -277,11 +289,21 @@
                        self::addReturnToModules( $out, $skin );
                }
 
-               if ( $wgGettingStartedRunTest && $user->isLoggedIn() ) {
-                       if( $out->getTitle()->inNamespace( NS_MAIN ) ) {
+               // Task Recommendations experiment v1.
+               if ( $wgGettingStartedRunTest ) {
+                       $bucket = 
self::getTaskRecommendationExperimentV1Bucket( $user );
+
+                       if (
+                               ( $bucket === 'post-edit' || $bucket === 
'post-edit-flyout' )
+                               && $out->getTitle()->inNamespace( NS_MAIN )
+                       ) {
                                $out->addModules( 
'ext.gettingstarted.lightbulb.postEdit' );
                        }
-                       if ( $user->getEditCount() > 0 ) {
+
+                       if (
+                               ( $bucket === 'flyout' || $bucket === 
'post-edit-flyout' )
+                               && $user->getEditCount() > 0
+                       ) {
                                $out->addModules( 
'ext.gettingstarted.lightbulb.flyout' );
                        }
                }
@@ -524,9 +546,11 @@
        public static function onPersonalUrls( &$personal_urls, &$title, 
$skinTemplate ) {
                global $wgGettingStartedRunTest, $wgUser;
 
+               $bucket = self::getTaskRecommendationExperimentV1Bucket( 
$wgUser );
+
                if (
                        $wgGettingStartedRunTest &&
-                       $wgUser->isLoggedIn() &&
+                       ( $bucket === 'flyout' || $bucket === 
'post-edit-flyout' ) &&
                        $wgUser->getEditCount() > 0
                ) {
                        $recommendations = array(

-- 
To view, visit https://gerrit.wikimedia.org/r/156256
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1604b364dade6027c28b92d6711a5182bba3e2ef
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GettingStarted
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: Swalling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to