Skip to content

Commit

Permalink
Fix Goals Controller regression in UI tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Nov 26, 2014
1 parent 32427de commit 8fafa66
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions plugins/Goals/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ private function formatConversionRate($conversionRate)
if ($conversionRate->getRowsCount() == 0) {
$conversionRate = 0;
} else {
$columns = $conversionRate->getFirstRow()->getColumns();
$conversionRate = (float)reset($columns);
$conversionRate = $conversionRate->getFirstRow()->getColumn('conversion_rate');
}
}
return sprintf('%.' . self::CONVERSION_RATE_PRECISION . 'f%%', $conversionRate);

if (!is_numeric($conversionRate)) {
$conversionRate = sprintf('%.' . self::CONVERSION_RATE_PRECISION . 'f%%', $conversionRate);
}

return $conversionRate;
}

public function __construct()
Expand Down Expand Up @@ -145,11 +149,13 @@ protected function getGoalReportView($idGoal = false)

// conversion rate for new and returning visitors
$segment = urldecode(\Piwik\Plugins\VisitFrequency\API::RETURNING_VISITOR_SEGMENT);
$conversionRateReturning = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$conversionRateReturning = Request::processRequest("Goals.get", array('segment' => $segment, 'idGoal' => $idGoal));
$view->conversion_rate_returning = $this->formatConversionRate($conversionRateReturning);

$segment = 'visitorType==new';
$conversionRateNew = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$conversionRateNew = Request::processRequest("Goals.get", array('segment' => $segment, 'idGoal' => $idGoal));
$view->conversion_rate_new = $this->formatConversionRate($conversionRateNew);

$view->goalReportsByDimension = $this->getGoalReportsByDimensionTable(
$view->nb_conversions, isset($ecommerce), !empty($view->cart_nb_conversions));
return $view;
Expand Down

0 comments on commit 8fafa66

Please sign in to comment.