You are here

class AcquiaLiftTestReports in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 tests/acquia_lift.test_classes.inc \AcquiaLiftTestReports

Class AcquiaLiftTestReports

Helper class providing static methods that return basic reports.

Hierarchy

Expanded class hierarchy of AcquiaLiftTestReports

File

tests/acquia_lift.test_classes.inc, line 330
Provides test classes for Acquia Lift

View source
class AcquiaLiftTestReports {
  public static function getBasicConfidenceReport($agent_name) {
    $report = array(
      'agent' => $agent_name,
      'dateFrom' => '2014-08-08',
      'dateThru' => '2014-08-08',
      'data' => array(
        'items' => array(
          0 => array(
            'owner' => 'test-owner-code',
            'agent' => $agent_name,
            'point' => 'osid-1',
            'choice' => 'osid-1:option-1',
            'seg' => '(none)',
            'feature' => '(none)',
            'goal' => NULL,
            'count' => 0,
            'val' => 0,
            'valSq' => 0,
            'goals' => 0,
            'goalsSq' => 0,
            'date' => '2014-08-08',
            'totals' => array(
              'count' => 0,
              'goals' => 0,
              'val' => 0,
              'goalsPerDecision' => 0,
              'valPerDecision' => 0,
              'valPerGoal' => 0,
            ),
            'label' => 'option-1',
            'bLo' => 0,
            'bHi' => 0,
            'vVari' => 0,
            'vMean' => 0,
            'stdDev' => 0,
            'tScore' => 0,
            'dgFree' => 0,
            'pValue' => -1,
            'signif' => false,
            'confidence' => '0.0',
            'confidenceLevel' => 0,
            'lift' => array(
              'default' => 0,
              'random' => 0,
            ),
            'ts' => 1407456000,
          ),
          1 => array(
            'owner' => 'test-owner-code',
            'agent' => $agent_name,
            'point' => 'osid-1',
            'choice' => 'osid-1:option-2',
            'seg' => '(none)',
            'feature' => '(none)',
            'goal' => NULL,
            'count' => 0,
            'val' => 0,
            'valSq' => 0,
            'goals' => 0,
            'goalsSq' => 0,
            'date' => '2014-08-08',
            'totals' => array(
              'count' => 0,
              'goals' => 0,
              'val' => 0,
              'goalsPerDecision' => 0,
              'valPerDecision' => 0,
              'valPerGoal' => 0,
            ),
            'label' => 'option-2',
            'bLo' => 0,
            'bHi' => 0,
            'vVari' => 0,
            'vMean' => 0,
            'stdDev' => 0,
            'tScore' => 0,
            'dgFree' => 0,
            'pValue' => -1,
            'signif' => false,
            'confidence' => '0.0',
            'confidenceLevel' => 0,
            'lift' => array(
              'default' => 0,
              'random' => 0,
            ),
            'ts' => 1407456000,
          ),
        ),
        'bLo' => NULL,
        'bHi' => NULL,
      ),
    );
    return $report;
  }

  /**
   * Generates confidence report data based on the passed in parameters.
   *
   * @param $agent_name
   *   The name of the agent to generate a report for.
   *
   * @param array $choices
   *   An array of options for which data should be generated, keyed by decision point
   *   name and with an array of all possible winning options or combinations of options
   *   as values. For multiple decisions at one point, i.e. an MVT, the choices should be
   *   flattened into decision combinations, e.g. 'dec-1:option-a,dec-2:option-b'. E.g.
   *   array(
   *     'my-first-decision-point' => array(
   *       'my-first-decision:option-A',
   *       'my-first-decision:option-B'
   *     ),
   *     'my-MVT-decision-point' => array(
   *       'dec-1:option-a,dec-2:option-a',
   *       'dec-1:option-a,dec-2:option-b',
   *       'dec-1:option-b,dec-2:option-a',
   *       'dec-1:option-b,dec-2:option-b',
   *      )
   *    )
   * @param array $winners
   *   Optionally specify a winning choice or combination for each decision point. The
   *   report data generated will then be such that that option or combination represents
   *   a winner.
   * @return array
   */
  public static function generateConfidenceReportWithWinners($agent_name, $choices, $winners = array()) {
    $today = time();
    $date_from = date('Y-m-d', $today);
    $date_to = date('Y-m-d', $today);
    $items = array();
    foreach ($choices as $point => $options) {

      // Start with dummy values which we'll just increment for each choice.
      $blo = 0.016;
      $vmean = 0.017;
      $bhi = 0.018;
      $num_decisions = 10;
      $num_goals = 100;
      foreach ($options as $i => $choice) {
        $items[$choice] = array(
          'owner' => 'test-owner-code',
          'agent' => $agent_name,
          'point' => $point,
          'choice' => $choice,
          'count' => $num_decisions + 10 * $i,
          'bLo' => $blo + 0.001 * $i,
          'bHi' => $bhi + 0.001 * $i,
          'vMean' => $vmean + 0.001 * $i,
        );
      }
      if (isset($winners[$point])) {

        // For the winning option, we need to make sure the vMean value is higher
        // than the others.
        $winning_blo = $vmean + 0.001 * (count($options) + 1);
        $winning_vmean = $winning_blo + 0.001;
        $winning_vhi = $winning_vmean + 0.001;
        $items[$winners[$point]]['bLo'] = $winning_blo;
        $items[$winners[$point]]['vMean'] = $winning_vmean;
        $items[$winners[$point]]['bHi'] = $winning_vhi;
      }
    }
    $report = array(
      'agent' => $agent_name,
      'dateFrom' => $date_from,
      'dateThru' => $date_to,
      'data' => array(
        'items' => array_values($items),
        'bLo' => NULL,
        'bHi' => NULL,
      ),
    );
    return $report;
  }
  public static function getBasicTargetingReport($agent_name) {
    $report = array(
      'agent' => $agent_name,
      'dateFrom' => '2014-08-08',
      'dateThru' => '2014-08-08',
      'data' => array(
        'items' => array(),
        'totals' => array(),
      ),
    );
    return $report;
  }
  public static function getBasicStatusReport($agent_name) {
    $report = array(
      'data' => array(
        $agent_name => array(
          'totals' => array(
            'goals' => array(
              'count' => 0,
            ),
            'sessions' => array(
              'count' => 0,
            ),
          ),
          'dates' => array(
            0 => array(
              'date' => 1407542400,
              'sessionCount' => 0,
              'goalCount' => 0,
              'goalValue' => 0,
              'liftOverDefaultUsingGoals' => 0,
              'liftOverDefaultUsingValue' => 0,
              'liftOverRandomUsingGoals' => 0,
              'liftOverRandomUsingValue' => 0,
              'goalsPerSession' => 0,
              'valuePerSession' => 0,
              'valuePerGoal' => 0,
              'liftOverDefaultUsingGoalsToDate' => 0,
              'liftOverRandomUsingGoalsToDate' => 0,
              'liftOverDefaultUsingValueToDate' => 0,
              'liftOverRandomUsingValueToDate' => 0,
            ),
          ),
          'trends' => array(
            'dates' => array(
              0 => 1407542400,
            ),
            'sessionCount' => array(
              0 => 0,
            ),
            'goalCount' => array(
              0 => 0,
            ),
            'goalValue' => array(
              0 => 0,
            ),
            'liftOverDefaultUsingGoals' => array(
              0 => 0,
            ),
            'liftOverDefaultUsingValue' => array(
              0 => 0,
            ),
            'liftOverRandomUsingGoals' => array(
              0 => 0,
            ),
            'liftOverRandomUsingValue' => array(
              0 => 0,
            ),
            'goalsPerSession' => array(
              0 => 0,
            ),
            'valuePerSession' => array(
              0 => 0,
            ),
            'valuePerGoal' => array(
              0 => 0,
            ),
            'liftOverDefaultUsingGoalsToDate' => array(
              0 => 0,
            ),
            'liftOverRandomUsingGoalsToDate' => array(
              0 => 0,
            ),
            'liftOverDefaultUsingValueToDate' => array(
              0 => 0,
            ),
            'liftOverRandomUsingValueToDate' => array(
              0 => 0,
            ),
          ),
          'today' => array(
            'date' => 1407542400,
            'sessionCount' => 0,
            'goalCount' => 0,
            'goalValue' => 0,
            'liftOverDefaultUsingGoals' => 0,
            'liftOverDefaultUsingValue' => 0,
            'liftOverRandomUsingGoals' => 0,
            'liftOverRandomUsingValue' => 0,
            'goalsPerSession' => 0,
            'valuePerSession' => 0,
            'valuePerGoal' => 0,
            'liftOverDefaultUsingGoalsToDate' => 0,
            'liftOverRandomUsingGoalsToDate' => 0,
            'liftOverDefaultUsingValueToDate' => 0,
            'liftOverRandomUsingValueToDate' => 0,
          ),
          'described' => '<p>Chooses <strong>adaptively</strong> from two options, <strong>test</strong> and <strong>some-custom-block</strong>.</p>
',
        ),
      ),
    );
    return $report;
  }
  public static function getBasicContextFilters() {
    $filters = array(
      'data' => array(
        'potential' => array(
          'features' => array(
            0 => array(
              'code' => '(none)',
              'name' => '(Any Visitor)',
            ),
          ),
        ),
      ),
    );
    return $filters;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaLiftTestReports::generateConfidenceReportWithWinners public static function Generates confidence report data based on the passed in parameters.
AcquiaLiftTestReports::getBasicConfidenceReport public static function
AcquiaLiftTestReports::getBasicContextFilters public static function
AcquiaLiftTestReports::getBasicStatusReport public static function
AcquiaLiftTestReports::getBasicTargetingReport public static function