diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-20 11:09:46 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-20 11:09:46 +0400 |
commit | 0a63210e3eae7562af1a3dbee340eb1ee140db3d (patch) | |
tree | c9f7c3a36a4b344b25c12aa04fed0733efb3bfa0 /core/DataAccess/LogAggregator.php | |
parent | 7ca35544d15cdb41b17283e693c8a14777c923ad (diff) |
Converting to namespace: Period*, Metrics, Segment, SegmentExpression, PluginsManager
Diffstat (limited to 'core/DataAccess/LogAggregator.php')
-rw-r--r-- | core/DataAccess/LogAggregator.php | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php index 0d51091fc7..e21ff15b5e 100644 --- a/core/DataAccess/LogAggregator.php +++ b/core/DataAccess/LogAggregator.php @@ -9,6 +9,8 @@ * @package Piwik */ use Piwik\Common; +use Piwik\Metrics; +use Piwik\Segment; use Piwik\Site; /** @@ -54,10 +56,10 @@ class Piwik_DataAccess_LogAggregator /** @var \Piwik\Site */ protected $site; - /** @var \Piwik_Segment */ + /** @var \Piwik\Segment */ protected $segment; - public function __construct(Piwik_Date $dateStart, Piwik_Date $dateEnd, Site $site, Piwik_Segment $segment) + public function __construct(Piwik_Date $dateStart, Piwik_Date $dateEnd, Site $site, Segment $segment) { $this->dateStart = $dateStart; $this->dateEnd = $dateEnd; @@ -75,27 +77,27 @@ class Piwik_DataAccess_LogAggregator protected function getVisitsMetricFields() { return array( - Piwik_Metrics::INDEX_NB_UNIQ_VISITORS => "count(distinct " . self::LOG_VISIT_TABLE . ".idvisitor)", - Piwik_Metrics::INDEX_NB_VISITS => "count(*)", - Piwik_Metrics::INDEX_NB_ACTIONS => "sum(" . self::LOG_VISIT_TABLE . ".visit_total_actions)", - Piwik_Metrics::INDEX_MAX_ACTIONS => "max(" . self::LOG_VISIT_TABLE . ".visit_total_actions)", - Piwik_Metrics::INDEX_SUM_VISIT_LENGTH => "sum(" . self::LOG_VISIT_TABLE . ".visit_total_time)", - Piwik_Metrics::INDEX_BOUNCE_COUNT => "sum(case " . self::LOG_VISIT_TABLE . ".visit_total_actions when 1 then 1 when 0 then 1 else 0 end)", - Piwik_Metrics::INDEX_NB_VISITS_CONVERTED => "sum(case " . self::LOG_VISIT_TABLE . ".visit_goal_converted when 1 then 1 else 0 end)", + Metrics::INDEX_NB_UNIQ_VISITORS => "count(distinct " . self::LOG_VISIT_TABLE . ".idvisitor)", + Metrics::INDEX_NB_VISITS => "count(*)", + Metrics::INDEX_NB_ACTIONS => "sum(" . self::LOG_VISIT_TABLE . ".visit_total_actions)", + Metrics::INDEX_MAX_ACTIONS => "max(" . self::LOG_VISIT_TABLE . ".visit_total_actions)", + Metrics::INDEX_SUM_VISIT_LENGTH => "sum(" . self::LOG_VISIT_TABLE . ".visit_total_time)", + Metrics::INDEX_BOUNCE_COUNT => "sum(case " . self::LOG_VISIT_TABLE . ".visit_total_actions when 1 then 1 when 0 then 1 else 0 end)", + Metrics::INDEX_NB_VISITS_CONVERTED => "sum(case " . self::LOG_VISIT_TABLE . ".visit_goal_converted when 1 then 1 else 0 end)", ); } static public function getConversionsMetricFields() { return array( - Piwik_Metrics::INDEX_GOAL_NB_CONVERSIONS => "count(*)", - Piwik_Metrics::INDEX_GOAL_NB_VISITS_CONVERTED => "count(distinct " . self::LOG_CONVERSION_TABLE . ".idvisit)", - Piwik_Metrics::INDEX_GOAL_REVENUE => self::getSqlConversionRevenueSum(self::TOTAL_REVENUE_FIELD), - Piwik_Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SUBTOTAL => self::getSqlConversionRevenueSum(self::REVENUE_SUBTOTAL_FIELD), - Piwik_Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_TAX => self::getSqlConversionRevenueSum(self::REVENUE_TAX_FIELD), - Piwik_Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SHIPPING => self::getSqlConversionRevenueSum(self::REVENUE_SHIPPING_FIELD), - Piwik_Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_DISCOUNT => self::getSqlConversionRevenueSum(self::REVENUE_DISCOUNT_FIELD), - Piwik_Metrics::INDEX_GOAL_ECOMMERCE_ITEMS => "SUM(" . self::LOG_CONVERSION_TABLE . "." . self::ITEMS_COUNT_FIELD . ")", + Metrics::INDEX_GOAL_NB_CONVERSIONS => "count(*)", + Metrics::INDEX_GOAL_NB_VISITS_CONVERTED => "count(distinct " . self::LOG_CONVERSION_TABLE . ".idvisit)", + Metrics::INDEX_GOAL_REVENUE => self::getSqlConversionRevenueSum(self::TOTAL_REVENUE_FIELD), + Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SUBTOTAL => self::getSqlConversionRevenueSum(self::REVENUE_SUBTOTAL_FIELD), + Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_TAX => self::getSqlConversionRevenueSum(self::REVENUE_TAX_FIELD), + Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SHIPPING => self::getSqlConversionRevenueSum(self::REVENUE_SHIPPING_FIELD), + Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_DISCOUNT => self::getSqlConversionRevenueSum(self::REVENUE_DISCOUNT_FIELD), + Metrics::INDEX_GOAL_ECOMMERCE_ITEMS => "SUM(" . self::LOG_CONVERSION_TABLE . "." . self::ITEMS_COUNT_FIELD . ")", ); } @@ -118,7 +120,7 @@ class Piwik_DataAccess_LogAggregator * @param bool|string $where Additional condition for WHERE clause * @param array $additionalSelects Additional SELECT clause * @param bool|array $metrics Set this if you want to limit the columns that are returned. - * The possible values in the array are Piwik_Metrics::INDEX_*. + * The possible values in the array are Metrics::INDEX_*. * @param bool|Piwik_RankingQuery $rankingQuery * A pre-configured ranking query instance that is used to limit the result. * If set, the return value is the array returned by Piwik_RankingQuery::execute(). @@ -137,19 +139,19 @@ class Piwik_DataAccess_LogAggregator $orderBy = false; if ($rankingQuery) { - $orderBy = '`' . Piwik_Metrics::INDEX_NB_VISITS . '` DESC'; + $orderBy = '`' . Metrics::INDEX_NB_VISITS . '` DESC'; } $query = $this->generateQuery($select, $from, $where, $groupBy, $orderBy); if ($rankingQuery) { - unset($availableMetrics[Piwik_Metrics::INDEX_MAX_ACTIONS]); + unset($availableMetrics[Metrics::INDEX_MAX_ACTIONS]); $sumColumns = array_keys($availableMetrics); if ($metrics) { $sumColumns = array_intersect($sumColumns, $metrics); } $rankingQuery->addColumn($sumColumns, 'sum'); - if ($this->isMetricRequested(Piwik_Metrics::INDEX_MAX_ACTIONS, $metrics)) { - $rankingQuery->addColumn(Piwik_Metrics::INDEX_MAX_ACTIONS, 'max'); + if ($this->isMetricRequested(Metrics::INDEX_MAX_ACTIONS, $metrics)) { + $rankingQuery->addColumn(Metrics::INDEX_MAX_ACTIONS, 'max'); } return $rankingQuery->execute($query['sql'], $query['bind']); } @@ -307,11 +309,11 @@ class Piwik_DataAccess_LogAggregator { $query = "SELECT name as label, - " . self::getSqlRevenue('SUM(quantity * price)') . " as `" . Piwik_Metrics::INDEX_ECOMMERCE_ITEM_REVENUE . "`, - " . self::getSqlRevenue('SUM(quantity)') . " as `" . Piwik_Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY . "`, - " . self::getSqlRevenue('SUM(price)') . " as `" . Piwik_Metrics::INDEX_ECOMMERCE_ITEM_PRICE . "`, - count(distinct idorder) as `" . Piwik_Metrics::INDEX_ECOMMERCE_ORDERS . "`, - count(idvisit) as `" . Piwik_Metrics::INDEX_NB_VISITS . "`, + " . self::getSqlRevenue('SUM(quantity * price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_REVENUE . "`, + " . self::getSqlRevenue('SUM(quantity)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY . "`, + " . self::getSqlRevenue('SUM(price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_PRICE . "`, + count(distinct idorder) as `" . Metrics::INDEX_ECOMMERCE_ORDERS . "`, + count(idvisit) as `" . Metrics::INDEX_NB_VISITS . "`, case idorder when '0' then " . Piwik_Tracker_GoalManager::IDGOAL_CART . " else " . Piwik_Tracker_GoalManager::IDGOAL_ORDER . " end as ecommerceType FROM " . Common::prefixTable('log_conversion_item') . " LEFT JOIN " . Common::prefixTable('log_action') . " @@ -337,7 +339,7 @@ class Piwik_DataAccess_LogAggregator * @param string $where where clause * @param array|bool $additionalSelects additional select clause * @param bool|array $metrics Set this if you want to limit the columns that are returned. - * The possible values in the array are Piwik_Metrics::INDEX_*. + * The possible values in the array are Metrics::INDEX_*. * @param Piwik_RankingQuery $rankingQuery pre-configured ranking query instance * @param bool|string $joinLogActionOnColumn column from log_link_visit_action that * log_action should be joined on. @@ -378,7 +380,7 @@ class Piwik_DataAccess_LogAggregator } if ($rankingQuery) { - $orderBy = '`' . Piwik_Metrics::INDEX_NB_ACTIONS . '` DESC'; + $orderBy = '`' . Metrics::INDEX_NB_ACTIONS . '` DESC'; } $query = $this->generateQuery($select, $from, $where, $groupBy, $orderBy); @@ -398,9 +400,9 @@ class Piwik_DataAccess_LogAggregator protected function getActionsMetricFields() { return $availableMetrics = array( - Piwik_Metrics::INDEX_NB_VISITS => "count(distinct " . self::LOG_ACTIONS_TABLE . ".idvisit)", - Piwik_Metrics::INDEX_NB_UNIQ_VISITORS => "count(distinct " . self::LOG_ACTIONS_TABLE . ".idvisitor)", - Piwik_Metrics::INDEX_NB_ACTIONS => "count(*)", + Metrics::INDEX_NB_VISITS => "count(distinct " . self::LOG_ACTIONS_TABLE . ".idvisit)", + Metrics::INDEX_NB_UNIQ_VISITORS => "count(distinct " . self::LOG_ACTIONS_TABLE . ".idvisitor)", + Metrics::INDEX_NB_ACTIONS => "count(*)", ); } |