Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/177191

Change subject: WIP track distinct experiments during campaign management
......................................................................

WIP track distinct experiments during campaign management

Just wondering what this might look like...  The prototype here will
create experiment entities as needed, and prompts the operator to
give them a description.

Change-Id: I5a333396ed14de02bc55fcc0afffc7c8d4c07ec5
---
M CentralNotice.hooks.php
M includes/Campaign.php
A includes/Experiment.php
M special/SpecialCentralNotice.php
4 files changed, 60 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice 
refs/changes/91/177191/1

diff --git a/CentralNotice.hooks.php b/CentralNotice.hooks.php
index 55cd063..948fa0c 100644
--- a/CentralNotice.hooks.php
+++ b/CentralNotice.hooks.php
@@ -87,6 +87,7 @@
        $wgAutoloadClasses[ 'CNBannerPager' ] = $includeDir . 
'CNBannerPager.php';
        $wgAutoloadClasses[ 'CNCampaignPager' ] = $includeDir . 
'CNCampaignPager.php';
        $wgAutoloadClasses[ 'CNDeviceTarget' ] = $includeDir . 
'CNDeviceTarget.php';
+       $wgAutoloadClasses[ 'Experiment' ] = $includeDir . 'Experiment.php';
        $wgAutoloadClasses[ 'GeoTarget' ] = $includeDir . 'GeoTarget.php';
        $wgAutoloadClasses[ 'IBannerMixin' ] = $includeDir . 'IBannerMixin.php';
        $wgAutoloadClasses[ 'AllocationContext' ] = $includeDir . 
'AllocationContext.php';
diff --git a/includes/Campaign.php b/includes/Campaign.php
index 7c65f1c..fa37d8b 100644
--- a/includes/Campaign.php
+++ b/includes/Campaign.php
@@ -1071,6 +1071,8 @@
         * @param $endAssignments   array of banner assignments after changes 
(optional)
         *
         * @return integer: ID of log entry (or null)
+        *
+        * TODO: call from a transactional CampaignStorage::save() handler.
         */
        static function logCampaignChange(
                $action, $campaignId, $user, $beginSettings = array(),
@@ -1079,6 +1081,7 @@
        ) {
                // TODO prune unused parameters
                // Only log the change if it is done by an actual user (rather 
than a testing script)
+               /// FIXME: this should not be conditional on user.
                if ( $user->getId() > 0 ) { // User::getID returns 0 for 
anonymous or non-existant users
                        $dbw = CNDatabase::getDb();
 
@@ -1153,6 +1156,17 @@
                }
                return $logs;
        }
+
+       /**
+        * @return Experiment
+        */
+       public function getCurrentExperiment() {
+               // select from cn_experiment
+               if ( !$experiment ) {
+                       // warning
+                       return Experiment::newFromCampaign( $this );
+               }
+       }
 }
 
 class CampaignExistenceException extends MWException {}
diff --git a/includes/Experiment.php b/includes/Experiment.php
new file mode 100644
index 0000000..6530d87
--- /dev/null
+++ b/includes/Experiment.php
@@ -0,0 +1,13 @@
+<?php
+
+class Experiment {
+       protected $description;
+
+       public static function newFromCampaign( Campaign $campaign ) {
+               // create a link table entry. serialize settings.
+       }
+
+       public function getDescription() {
+               return $this->description;
+       }
+}
diff --git a/special/SpecialCentralNotice.php b/special/SpecialCentralNotice.php
index 893bacb..b9711f6 100644
--- a/special/SpecialCentralNotice.php
+++ b/special/SpecialCentralNotice.php
@@ -195,6 +195,8 @@
                                        }
                                }
 
+                               // XXX check whether we should declare a new 
experiment.
+
                                // If there were no errors, reload the page to 
prevent duplicate form submission
                                if ( !$this->centralNoticeError ) {
                                        $out->redirect( 
$this->getPageTitle()->getLocalUrl() );
@@ -675,6 +677,15 @@
                // Begin Campaign detail fieldset
                $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
 
+               $messages = $this->calculateCampaignWarnings( $c );
+               // Attachment point for messages
+               //FIXME: Andrew is probably way ahead of me with the same 
feature.  Or, look
+               // around for notification precedents in core.
+               $htmlOut .= Xml::tags( 'div',
+                       array( 'class' => 'cn-messages' ),
+                       $messages
+               );
+
                if ( $this->editable ) {
                        $htmlOut .= Xml::openElement( 'form',
                                array(
@@ -736,6 +747,27 @@
        }
 
        /**
+        * @return HTML for output
+        */
+       function calculateCampaignWarnings( Campaign $campaign ) {
+               $htmlOut = '';
+
+               // TODO: test for campaign buckets without an assigned banner.
+
+               // If this campaign contains a new test, check that it has been 
given a
+               // name.
+               if ( $campaign->getCurrentExperiment()->getDescription() ) {
+                       $htmlOut .= Xml::tags( 'div',
+                               array( 'class' => 'warning' ),
+                               "This is a new test.  Please <input 
name=\"test_description\"
+                               type=\"text\" value=\"describe\" /> what is 
under test."
+                       );
+               }
+
+               return $htmlOut;
+       }
+
+       /**
         * Create form for managing campaign settings (start date, end date, 
languages, etc.)
         */
        function noticeDetailForm( $notice ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a333396ed14de02bc55fcc0afffc7c8d4c07ec5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

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

Reply via email to